diff options
author | Nipun Garg | 2019-05-29 02:01:28 +0530 |
---|---|---|
committer | Eugene Sandulenko | 2019-09-03 17:16:41 +0200 |
commit | 208c6430d6a7312f8c877cada1468be4749868b2 (patch) | |
tree | fe22bbb52858e0306cf23b4fafbc9ecec321ca45 | |
parent | 6082037f740fe42b2d77a214d45fd6ec24d57625 (diff) | |
download | scummvm-rg350-208c6430d6a7312f8c877cada1468be4749868b2.tar.gz scummvm-rg350-208c6430d6a7312f8c877cada1468be4749868b2.tar.bz2 scummvm-rg350-208c6430d6a7312f8c877cada1468be4749868b2.zip |
HDB: Add the GameState and State Management
-rw-r--r-- | engines/hdb/console.cpp | 2 | ||||
-rw-r--r-- | engines/hdb/hdb.cpp | 59 | ||||
-rw-r--r-- | engines/hdb/hdb.h | 32 |
3 files changed, 81 insertions, 12 deletions
diff --git a/engines/hdb/console.cpp b/engines/hdb/console.cpp index 65e8dba666..479cde0761 100644 --- a/engines/hdb/console.cpp +++ b/engines/hdb/console.cpp @@ -35,4 +35,4 @@ Console::~Console() { _visible = false; } -} // End of namespace Plumbers +} // End of namespace HDB diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp index f9c360c375..aa5f2c7381 100644 --- a/engines/hdb/hdb.cpp +++ b/engines/hdb/hdb.cpp @@ -28,7 +28,6 @@ #include "common/file.h" #include "common/error.h" #include "graphics/surface.h" -#include "graphics/palette.h" #include "hdb.h" #include "console.h" @@ -47,16 +46,68 @@ HDBGame::~HDBGame() { DebugMan.clearAllDebugChannels(); } +bool HDBGame::init() { + voiceless = false; + + /* + Game Subsystem Initializations + */ + + // Init _fileMan + if (_fileMan->openMPC("hyperdemo.mpc")) { + gameShutdown = false; + return true; + } + + error("FileMan::openMPC: Cannot find the hyperspace.mpc data file."); + return false; +} + +void HDBGame::start() { + gameState = GameState::GAME_TITLE; +} + +/* + Changes the current GameState to the next one. + Game State Transitions are deterministic: each state can + only a particular state. The next state is held in gameState. + + TODO: All the functionality hasn't been implemented yet since + their subsystems are incomplete. This section needs to be periodically + updated as soon as the subsytems are improved. +*/ +void HDBGame::changeGameState() { + + switch (gameState) { + case GameState::GAME_TITLE: + gameState = GameState::GAME_MENU; + break; + case GameState::GAME_MENU: + gameState = GameState::GAME_PLAY; + break; + case GameState::GAME_PLAY: + gameState = GameState::GAME_MENU; + break; + } +} + Common::Error HDBGame::run() { // Initializes Graphics Graphics::PixelFormat format(4, 8, 8, 8, 8, 24, 16, 8, 0); initGraphics(800, 600, &format); _console = new Console(); - //readMPC("hyperdemo.mpc"); + /* + if (!_game->init()) { + error("Couldn't initialize Game."); + return Common::kUnknownError; + } - Common::String s1("Tests"); - + _game->start(); + + _game->mainLoop(); + */ + while (!shouldQuit()) { Common::Event event; diff --git a/engines/hdb/hdb.h b/engines/hdb/hdb.h index 74284a590d..3a24d3bba4 100644 --- a/engines/hdb/hdb.h +++ b/engines/hdb/hdb.h @@ -35,16 +35,13 @@ #include "engines/util.h" #include "console.h" +#include "game.h" +#include "file-manager.h" + #define MAX_SNDCACHE_MEM 0x400000 // 4Mb of sounds in memory #define MAX_TILES_CACHED 3500 // Max no of tiles in memory at once #define GFX_CACHE_LIMIT 0x800000 -/* - Subsystem Includes -*/ - -#include "file-manager.h" - struct ADGameDescription; namespace HDB { @@ -54,6 +51,13 @@ enum HDBDebugChannels { kDebugExample2 = 1 << 1 }; +enum GameState { + GAME_TITLE, + GAME_MENU, + GAME_PLAY, + GAME_LOADING +}; + class HDBGame : public Engine { public: HDBGame(OSystem *syst, const ADGameDescription *gameDesc); @@ -66,6 +70,15 @@ public: const char *getGameId() const; Common::Platform getPlatform() const; + // Game related members; + + bool init(); + + void start(); + void changeGameState(); + + bool gameShutdown; + private: Console *_console; @@ -74,7 +87,12 @@ private: */ FileMan* _fileMan; - + + // Game Variables + + GameState gameState; + bool voiceless; + }; }// End of namespace HDB |