nsnake
Classic snake game for the terminal
GameState.hpp
1 #ifndef GAMESTATE_H_DEFINED
2 #define GAMESTATE_H_DEFINED
3 
31 class GameState
32 {
33 public:
39  enum StateCode
40  {
41  // Internal codes for quitting and continuing
42  QUIT, CONTINUE,
43 
44  // The actual game screens
45  MAIN_MENU,
46  GAME_START,
47  GAME_OVER
48  };
49 
50  // Left this here just because.
51  virtual ~GameState() {};
52 
58  virtual void load(int stack=0) = 0;
59 
64  virtual int unload() = 0;
65 
72  virtual StateCode update() = 0;
73 
75  virtual void draw() = 0;
76 
77 private:
78 };
79 
80 #endif //GAMESTATE_H_DEFINED
81 
virtual void draw()=0
Called every frame, where states draw stuff on screen.
virtual int unload()=0
Where every state destroys it's resources.
virtual StateCode update()=0
Called every frame, where states calculate everything that can change.
virtual void load(int stack=0)=0
Where every state initializes it's resources.
Abstract definition of a game state.
Definition: GameState.hpp:31
StateCode
All possible transitions between states.
Definition: GameState.hpp:39