Tuesday, September 4, 2012

Day 14 - Refactoring

I made some very big changes to the underlying engine of my game. Hopefully by the time I'm done, adding in new features will be a breeze.

I changed the GameObject class in a big way. Previously, all game objects were required to have a Sprite associated with it. Now, each object can decide for itself whether it wants to display a Sprite, Animation, or something else. I made the Draw and GetBoundingRectangle methods abstract, which means that all classes that inherit from GameObject must implement these methods. This cleaned up my code immensely, but each object needed to be refactored to accommodate the change.

Next I got rid of the animation handler. Now I'm treating all animations the same way as sprites, which means that they need to draw and update themselves.

Finally, I renamed the "Tile Manager" to "Level Generator" which will read the level file and add all objects to the screen. This part isn't finished yet because I ran out of time, but it will solve number 1 and 2 of my previous post.

No video for today because the collision detection is currently broken!

No comments:

Post a Comment