2011-06-28 02:07:52 +00:00
|
|
|
/* This is the heart of the application - the main game state where we are
|
|
|
|
actually playing.
|
2011-06-22 20:12:22 +00:00
|
|
|
|
2011-06-28 02:07:52 +00:00
|
|
|
This contains the basic game logic.
|
2011-06-22 20:12:22 +00:00
|
|
|
*/
|
|
|
|
|
2011-06-28 02:07:52 +00:00
|
|
|
#ifndef _GAME_H_
|
|
|
|
#define _GAME_H_
|
2011-06-22 20:12:22 +00:00
|
|
|
|
2011-06-23 21:28:49 +00:00
|
|
|
#include "gamedata.h"
|
2011-06-28 02:07:52 +00:00
|
|
|
#include "gamestate.h"
|
2011-07-02 21:34:11 +00:00
|
|
|
#include "menubutton.h"
|
2011-07-01 17:15:30 +00:00
|
|
|
#include <SDL_ttf.h>
|
2011-07-03 14:12:47 +00:00
|
|
|
#include <list>
|
|
|
|
#include <stack>
|
2011-06-28 02:07:52 +00:00
|
|
|
|
2011-07-03 14:12:47 +00:00
|
|
|
using std::list;
|
2011-06-28 02:07:52 +00:00
|
|
|
using std::stack;
|
|
|
|
|
2011-06-23 19:10:40 +00:00
|
|
|
|
2011-06-28 02:07:52 +00:00
|
|
|
class Game : public GameState
|
2011-06-22 20:12:22 +00:00
|
|
|
{
|
|
|
|
public:
|
2011-06-30 21:21:46 +00:00
|
|
|
Game(stack<GameState*>* state_stack, SDL_Surface* display);
|
2011-06-28 02:07:52 +00:00
|
|
|
~Game();
|
|
|
|
|
|
|
|
bool init();
|
2011-06-22 20:12:22 +00:00
|
|
|
|
|
|
|
protected:
|
2011-06-29 01:38:18 +00:00
|
|
|
void render();
|
|
|
|
void iterate() {}
|
|
|
|
|
2011-06-22 20:12:22 +00:00
|
|
|
// event handlers
|
2011-06-22 21:57:44 +00:00
|
|
|
void on_lbutton_down(int x, int y);
|
2011-06-23 19:10:40 +00:00
|
|
|
void on_rbutton_down(int mX, int mY);
|
2011-06-24 13:48:59 +00:00
|
|
|
void on_key_down(SDLKey sym, SDLMod mod, Uint16 unicode);
|
2011-07-02 21:34:11 +00:00
|
|
|
void on_mouse_move(int mX, int mY, int relX, int relY, bool left,
|
|
|
|
bool right, bool middle);
|
2011-06-24 13:48:59 +00:00
|
|
|
|
2011-06-22 20:12:22 +00:00
|
|
|
private:
|
2011-07-03 20:57:47 +00:00
|
|
|
void draw_stats(GameVertex* v);
|
2011-07-02 21:34:11 +00:00
|
|
|
void draw_button(MenuButton* button);
|
2011-07-03 20:57:47 +00:00
|
|
|
void draw_node(GameVertex* v);
|
2011-07-04 05:27:56 +00:00
|
|
|
void draw_player_info();
|
2011-06-22 20:12:22 +00:00
|
|
|
|
2011-07-03 14:12:47 +00:00
|
|
|
void handle_button_press(ButtonAction action);
|
|
|
|
|
2011-06-22 21:57:44 +00:00
|
|
|
// data
|
2011-06-23 21:28:49 +00:00
|
|
|
GameData data;
|
2011-07-02 21:34:11 +00:00
|
|
|
// the x,y position of the mouse cursor
|
|
|
|
int cursor_x;
|
|
|
|
int cursor_y;
|
2011-06-28 02:35:52 +00:00
|
|
|
|
|
|
|
// surfaces containing textures to draw
|
|
|
|
SDL_Surface* background;
|
2011-07-01 17:15:30 +00:00
|
|
|
TTF_Font* font;
|
2011-07-03 19:16:00 +00:00
|
|
|
SDL_Surface* attacker_icon;
|
|
|
|
SDL_Surface* defender_icon;
|
|
|
|
SDL_Surface* producer_icon;
|
2011-07-02 00:00:19 +00:00
|
|
|
|
2011-07-02 21:34:11 +00:00
|
|
|
// menu buttons
|
2011-07-03 14:12:47 +00:00
|
|
|
list<MenuButton*> buttons;
|
2011-07-02 21:34:11 +00:00
|
|
|
|
|
|
|
static int NODE_RADIUS;
|
|
|
|
|
2011-07-02 00:00:19 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
void print_debug_info();
|
|
|
|
#endif
|
2011-06-22 20:12:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|