02 December 2009

Putting the code into XNA, part 2

I added a GameMode class to handle the succession of different modes that happen within the game, starting with the following :-

Player 1 rolls the dice,
Player 1 enters a move,
Make player 1's first move,
Player 1 enters second move,
Make player 1's second move,
Player 2 rolls the dice,
Player 2 generates 2 moves,
Make player 2's 1st move,
Make player 2's 2nd move

After player 2 has moved the game loops back to player 1's turn.

I found it best to keep to keep the Draw method just for displaying the board and all the changes to the gamemode in the Update method of the game loop.

So the game Update method contains a switch statement similar to this...

switch (GameMode.State)
{
case GameMode.Player0RollingDice:
{
Dice.Roll();
GameMode.State = GameMode.Player0Input1;
break;
}
case...

No comments: