My work recently did a day called Open Space (I believe the thought was that it would replace what we previously did called Hack-a-thons). I had no idea what to think going to Open Space and it turns out to be a great idea. Whatever happens was meant to happen. Anyway, if you haven't done an Open Space, it is a cool idea and worth doing. What happened at our first Open Space is that I decided to host a session about learning C#. Turns out it was a popular session, I think we had 15 people in the session. I better know my stuff!
At the session I talked about what I was doing with the C# book, Code Newbies, Code Wars, and just trying to pick up stories at work. We walked through an example of the last program I wrote and everyone was interested in my blog. Well, it has been a couple weeks since I wrote a post on my coding. I have been working on the latest and greatest game, The Quest. I have been slow going and spending time when I can find it to work on this project. This is a lab though and there is no help. I have been making sure I understand what I am doing with the code and it is taking a while. So far, I believe I have most of it written, I need to write what each of the available weapons do and then wire up the Windows Form to start working. I neglected to write more about the process while I was doing and it turns out that people are actually reading my blog. I was asked today if I was going to blog about the time I was spending on this project. Short story, people read my blog and about the adventures I have embarked on.
Now, onto The Quest.
The picture is the base for the form, it contains all the pictures that will be needed for each level. The form will control when the weapons are picked up and which enemies are present for the level. Well, I get to use inheritance quiet often in this project. I have a Mover class, and abstract Enemy class (which inherits from Mover), three different types of Enemy (inherits from Enemy class), a Player class (inherits from Mover), and the weapon classes (also inherits from the Mover class). My move class controls a large number of what the game does.
To make sure I have good encapsulation, I have the form that will only call the Game class and the Game class will call the correct methods from each of their respective classes. Now, I am having a problem, I am having a hard time deciding which class that methods best fit and if I need to have a private object or public objects.
I talked to my team lead about the problems I was having with this. I just needed a gentle reminder, Private objects will only be used in their class. Objects should only be public when they will be called by another class. To better encapsulate our objects we call the public object, but the private is the only one that can change our public object.
As I have been writing the code and following the "hints" I am given from the book, I have gotten a few errors, like I created a method using public abstract string Name. I had the lovely red squiggly lines in VS. Hey, you can't have an abstract method when the class isn't abstract! The error was pretty helpful, it still took me a few minutes to realize what the error was telling me. I got it. Another error I got while working on the Weapon class. Below is the picture:
The NearBy class only has two arguments. I remembered this one pretty quick, I need to overload this method and have it use have one method with two arguments and the overloaded method taking three arguments.
I am also overriding a method called Move for each of my enemy types. Honestly, this confuse me for a minute on what I needed to call. I had the example the book gave me for the Mover class with the Move method. The enemies need to find out where the player is to determine which direction to move. I forgot that I had method in the Game class that determines where the player is at and the enemy class instantiates a game class.
Things are starting to come together and, after I think about what needs to be done for a while, I have started realizing what needs to be done. It is slow going, but I hope I become better and more efficient with the coding and realizing what needs to be done. Maybe I can give you The Quest in the next week.
Thanks for reading, I'm off to read The Marian.