*Warning* Some programmer talk here, skip to the next paragraph if you're not interested*
Today I made a push to start implementing more game modes without gutting the existing game functionality. The existing general game logic is working very nicely, which you've seen from my previous blog posts. One thing I'm fighting against is the code isn't well organized given how fast I had to create it. The majority of the game logic is in one class, however there are some snippets in other areas as well. I don't want to start modifying that too much in order to implement new game specific logic. In the past I would have used inheritance to extend the existing game logic class and add the new game specific stuff. However since the logic is a bit scattered, and that fragmentation will likely get worse as I continue, I decided to try something different: a form of composition. For each new game mode, I create a custom game logic class that registers delegate callbacks for certain events generated by the core game logic. This lets me modify certain areas of the game, and add entirely new things, without changing the underlying game.
|Very simple code org. chart|
I put up a web build of the game here for those feeling adventurous. There are no directions on how to play, no scoring and no end goal, this is just to show off the mechanics I have in there right now. Feel free to leave comments/suggestions if you have any. Depending on how productive I am, tomorrow I'll try to add a build with one of the new game modes implemented.
UPDATE - I'm told by Bryce, who gave me the blocks, that the blocks aren't rotated correctly. Guess I'll add this to the blooper reel. Tomorrow's update with show a better view of them.
In case you missed it, link to the web build: Build1