diff options
author | Thorbjørn Lindeijer <thorbjorn@lindeijer.nl> | 2010-02-05 22:15:43 +0100 |
---|---|---|
committer | Thorbjørn Lindeijer <thorbjorn@lindeijer.nl> | 2010-02-06 21:25:37 +0100 |
commit | 242e3bb8d92def67d5c30f2f2fd974cfb117ec04 (patch) | |
tree | 7f247e04e238a0edc0281ec8ed85539b2be81137 /src/game.h | |
parent | 51e14c9d7aab75fe60f68d4943759eef66eafe9a (diff) | |
download | mana-242e3bb8d92def67d5c30f2f2fd974cfb117ec04.tar.gz mana-242e3bb8d92def67d5c30f2f2fd974cfb117ec04.tar.bz2 mana-242e3bb8d92def67d5c30f2f2fd974cfb117ec04.tar.xz mana-242e3bb8d92def67d5c30f2f2fd974cfb117ec04.zip |
Merged the Engine class into the Game class
There was little point in keeping the Engine class separate. It wasn't
an engine at all, but only kept track of the currently active map, a job
more suitable for the Game class anyway.
Diffstat (limited to 'src/game.h')
-rw-r--r-- | src/game.h | 39 |
1 files changed, 36 insertions, 3 deletions
@@ -1,6 +1,6 @@ /* * The Mana World - * Copyright (C) 2004 The Mana World Development Team + * Copyright (C) 2004-2010 The Mana World Development Team * * This file is part of The Mana World. * @@ -30,26 +30,54 @@ extern volatile int fps; extern volatile int tick_time; extern const int MILLISECONDS_IN_A_TICK; +class Map; class WindowMenu; +/** + * The main class responsible for running the game. + */ class Game : public ConfigListener { public: + /** + * Constructs the game, creating all the managers, handlers, engines + * and GUI windows that make up the game. + */ Game(); + /** + * Destructor, cleans up the game. + */ ~Game(); - void logic(); + /** + * Provides access to the game instance. + */ + static Game *instance() { return mInstance; } + + /** + * This method runs the game. It returns when the game stops. + */ + void exec(); void handleInput(); void optionChanged(const std::string &name); + void changeMap(const std::string &mapName); + + /** + * Returns the currently active map. + */ + Map *getCurrentMap() { return mCurrentMap; } + + const std::string &getCurrentMapName() { return mMapName; } + private: /** Used to determine whether to draw the next frame. */ int mDrawTime; - /** The minimum frame time (used for frame limiting). */ + /** The minimum frame time in ms (used for frame limiting). */ int mMinFrameTime; int mLastTarget; @@ -58,6 +86,11 @@ class Game : public ConfigListener SDL_TimerID mSecondsCounterId; WindowMenu *mWindowMenu; + + Map *mCurrentMap; + std::string mMapName; + + static Game *mInstance; }; /** |