Refactored code heavily to be able to use a state stack - main function now does the basic init, looping, and shutdown, and each state is a pointer to an object that has its own event handling, rendering, etc
This commit is contained in:
46
game.h
Normal file
46
game.h
Normal file
@ -0,0 +1,46 @@
|
||||
/* This is the heart of the application - the main game state where we are
|
||||
actually playing.
|
||||
|
||||
This contains the basic game logic.
|
||||
*/
|
||||
|
||||
#ifndef _GAME_H_
|
||||
#define _GAME_H_
|
||||
|
||||
#include "gamedata.h"
|
||||
#include "sdlrenderer.h"
|
||||
#include "gamestate.h"
|
||||
#include <stack>
|
||||
|
||||
using std::stack;
|
||||
|
||||
|
||||
class Game : public GameState
|
||||
{
|
||||
public:
|
||||
Game() {}
|
||||
~Game();
|
||||
|
||||
bool init();
|
||||
void execute(stack<GameState*> &state_stack) throw(StateExit);
|
||||
|
||||
protected:
|
||||
// event handlers
|
||||
void on_exit();
|
||||
void on_lbutton_down(int x, int y);
|
||||
void on_rbutton_down(int mX, int mY);
|
||||
void on_key_down(SDLKey sym, SDLMod mod, Uint16 unicode);
|
||||
|
||||
private:
|
||||
void render();
|
||||
|
||||
SDLRenderer renderer;
|
||||
|
||||
// data
|
||||
GameData data;
|
||||
|
||||
static int NODE_RADIUS;
|
||||
static int MAX_MOVE_DISTANCE;
|
||||
};
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user