Wednesday, May 1, 2013

Bomb Diggity - Handling Game States

In the latest rendition of Bomb Diggity, I came across the problem of retaining the same game state when accessing our in-game store menu. Due to how it was originally coded we'd erase the game state when accessing the store since we had intended for it to be a mid-point between accessing new levels. But now that Bomb Diggity has been coded to allow the player to access the store mid-game I realized that we'd be destroying the player's current field, thus not giving them the option to continue with the same level without having to restart.

Example of Problem

The solution that I came up with to fix this problem was changing how our game states were handled. Instead of deleting and recreating the same level whenever we entered the shop, I coded it so that the game states existed simultaneously. By creating both the level and the shop simultaneously the player was able to enter the shop without wiping away their current progress. A minor problem arose since both of them existed simultaneously and the shop was overlapping the level and not allowing the player to actually play the game. That was fixed by altering the "Visible" variable included with the game state and making the shop not visible to the players. Then when it was necessary to enter the shop all that needed to be done was change the variables so that the shop became the visible layer and the game level became invisible; then once the player is done it is simple to reverse the process and leave them right where they left off.

 Example After Fixing Code

No comments:

Post a Comment