Game Development Reference
In-Depth Information
The
PersistentGameData
class will have a description of the current level
and information about whether the player has just won that level.
class PersistantGameData
{
public bool JustWon { get; set; }
public LevelDescription CurrentLevel { get; set; }
public PersistantGameData()
{
JustWon
¼
false;
}
}
The
JustWon
member is set to
false
in the constructor because the player
cannot have won a game before the game data is created. The persistent game
data class needs to be created in the Form.cs file. Add a new function to be called
from the constructor called
InitializeGameData
; it should be called just
after
InitializeTextures
and just before the game fonts are created.
PersistantGameData _persistantGameData
¼
new PersistantGameData();
private void InitializeGameData()
{
LevelDescription level
¼
new LevelDescription();
level.Time
¼
1; // level only lasts for a second
_persistantGameData.CurrentLevel
¼
level;
}
With this class set up it's now easy to design the
InnerGameState
.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Engine;
using Engine.Input;
using Tao.OpenGl;
namespace Shooter
{
class InnerGameState : IGameObject
{
Renderer _renderer
¼
new Renderer();
Search WWH ::
Custom Search