Sunday, July 7, 2013

July 7: Game States in Dodge Arena

Hey all!

In terms of features to show off, little to nothing happened today in Dodge Arena. One thing I did implement, however, was the idea of game states. Basically, I have something called a StateManager which I can call to change states. 'States' in this case refer to things like being in the game, the main menu, the options menu, etc. Earlier, since I was just rushing to get something onto the screen, it was very inelegant; I had it such that, for example, clicking 'New Game' created a Game world right there. Instead, now, I have this very simple line:
if self.text == "New Game":
     mainMenuState.getManager().changeState(1)

The state manager knows that '1' means 'GameState' and destroys the menu state and creates the game state accordingly. I needed to do this in order to do what I am doing next, which is the in-game menu (Where I need the functionality that, if the player hits escape, the game freezes while I show them a menu to choose options from). So there's nothing to show off today, it was mostly all behind-the-scenes stuff cleaning up messy code in implementing 'correct' design concepts. Tomorrow I'll hopefully have some screenshots or a video of an in-game menu, and possibly some walls or monsters.

P.S., huge shoutout to SyntaxHighlighter for creating an awesome JavaScript library to show off code on Blogger, and CraftFella for his blog post on how to install it. Thanks guys!

No comments:

Post a Comment