/* * Copyright (C) 2002,2003 Daniel Heck * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. * * $Id: game.hh,v 1.1 2003/01/12 19:38:04 dheck Exp $ */ namespace enigma { class Game { public: Game(); void run(LevelPack *lp, int ilevel); void quit() { change_state(ABORT); } void finish_level() { change_state(LEVELFINISHED); } void restart_level() { change_state(RELOADLEVEL); } private: // Private types. enum State { /* The game is currently running. */ INGAME, /* This level has been completed, proceed to the next one. */ LEVELFINISHED, /* Player's marble is dead. Wait a little, then restart the level. */ PLAYERDEAD, /* Restart the game. */ RESTARTGAME, /* Reload the current level (this automatically resets every object in the landscape). */ RELOADLEVEL, /* The level info screen before entering a new level. */ LEVELINFO, /* Leave the game immediately. */ ABORT }; // Private methods. void handle_events(); void on_keydown(SDL_Event &e); void on_mousebutton(SDL_Event &e); void update_mouse_button_state(); void change_state(State newstate); void tick(double dtime); void show_menu(); bool load_level(int ilevel); // Private variables. State state; enum InputState { I_NORMAL, I_MESSAGE, I_COMMAND } input_state; LevelPack *level_pack; unsigned icurrent_level; Uint32 last_tick_time; double level_finished_dtime; double actor_dead_dtime; px::Screen *screen; }; }