Thank you for visiting Blazing Games

Finishing the Game

At this point we have a playable single player game so it is probably a good time to finally start writing the manager. There are two routes we can take with the manager. Since Flash CS3 lets you have the main movie reference an external class for it's code we could have it be the actual main movie clip. Alternatively we could have it be a separate movie clip class that the main movie clip creates. As there is a possibility that this game is going to be part of a larger collection of games, I think that the second option might be the better approach as it is a very simple task to create a full screen rectangle movie clip that uses the ThirtySixManager class as the linkage class. However, why have an empty movie clip or a solid rectangle when we can distinguish the players by using colors. We can even manually place the six player movies on the clip saving us a bit of initialization work.

The main game play loop is simple and is activated every time the player has finished a turn and sent an event to the manager. Here the game loops through the players trying to find a player who has not yet finished their game and gives this player an opportunity to play. If there are no players that meet this criteria, then the game is over. At this point there are three possibilities. First, that there is a single winner, in which the winning player's state is set to win and they get some points. Second that there is multiple winners in which case each player involved in the tie is given a point and their state is set to tie. The third state where every player has died should never happen, but needs to be accounted for as there are stupid people in the world and if the last player to not have died is too dumb not to stand they could end up causing this state.

Now that we have the game fully playable, it is time to add the computer opponent for cases where you want to play this game alone. Another feature AI can be used for is to test the game as letting the game be played entirely by AI players is a very rapid way of repeatedly playing the game. This is where an interesting minor bug was discovered and fixed. As I created a toggle button for switching between the human and computer modes, it is possible to switch a player to computer when it is that player's turn. In such a case the computer does not make a move. This was easily solved by moving the AI code to a separate function which gets called in the case that the current player is switched to AI during their turn. The AI is very simple and simply tries to get a score of 33 or higher.

Adding some buttons to start a new round and return to the title was easy enough. As was the title screen. With that added we have a finished game.

Previous page
Making Thirty Six Page 4

About - Privacy Policy - Contact - Links - FAQ
Copyright © 2008 Blazing Games Inc. All Rights Reserved