Game Development Reference
In-Depth Information
#endregion
}
}
The constructor takes in the state system and persistent game data. Using these
classes the InnerGameState can determine when the game is over and change
the game state. The constructor also takes in the input and general font as these
will be of use when adding the second pass of functionality. The constructor calls
OnGameStart , which sets the gameTime that will determine how long the
level lasts. There will be no level content at this time so the level time is set to
1 second.
The Update function counts down the level time. When the time is up it and the
state changes to game_over . The gameTime is reset by calling OnGameState
and because the player is still alive then, the JustWon flag is set in the persistent
data object. The inner game state Render function clears the screen to a pink
color so it's obvious when the state change occurs.
The InnerGameState class should be used to add another state to the state
system in the Form.cs file.
_system.AddState("inner_game", new InnerGameState(_system, _input,
_persistantGameData, _generalFont));
That's it for the first pass of the inner game.
The Game Over State
The gameover state is a simple state that tells the player that the game has
ended and if he won or lost. The state determines if the player won or lost
the game by using the PersistentGameData class. The state will display
its information for a short time and then return the player to the start menu.
The player can return to the start menu earlier by pressing a button and forcing
the GameOverState to finish.
%using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Engine;
using Engine.Input;
 
Search WWH ::




Custom Search