From cbcc1b180263b3dfad8dd874e37b63799db02a8f Mon Sep 17 00:00:00 2001 From: Alfred Burgess <alfred.burgess95@gmail.com> Date: Fri, 5 Jan 2024 02:41:59 +0800 Subject: [PATCH] Removed surpurfluous code from main and moved into the game engine --- include/game-engine.h | 2 ++ include/game-state.h | 4 ++++ src/game-engine.cpp | 1 + src/main.cpp | 39 --------------------------------------- 4 files changed, 7 insertions(+), 39 deletions(-) diff --git a/include/game-engine.h b/include/game-engine.h index 3a564b5..d5a7f7c 100644 --- a/include/game-engine.h +++ b/include/game-engine.h @@ -12,6 +12,7 @@ #include "logger.h" #include "entity-manager.h" +#include "game-state.h" #include "scene.h" #include "asset.h" #include "save-manager.h" @@ -43,6 +44,7 @@ class GameEngine void handleInput(); private: SaveManager _saveManager; + GameState _state = Uninitialised; size_t _frame = 0; std::time_t _frametime = 0; EntityManager _entityManager; diff --git a/include/game-state.h b/include/game-state.h index fa1f9df..0743d2e 100644 --- a/include/game-state.h +++ b/include/game-state.h @@ -1,3 +1,5 @@ +#ifndef __GAME_STATE__H__ +#define __GAME_STATE__H__ enum GameState { Uninitialised, @@ -6,3 +8,5 @@ enum GameState Active, Exit }; + +#endif // __GAME_STATE__H__ \ No newline at end of file diff --git a/src/game-engine.cpp b/src/game-engine.cpp index 678c13d..e63215f 100644 --- a/src/game-engine.cpp +++ b/src/game-engine.cpp @@ -15,6 +15,7 @@ void GameEngine::init() { this->isRunning = false; this->_currScene = ""; + this->_state = Initialise; // this->_saveManager.list(); } void GameEngine::changeScene( std::string label, Scene* scene ) diff --git a/src/main.cpp b/src/main.cpp index 7cc2341..307e370 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3,54 +3,15 @@ #ifndef __TEST_RUNNER__ int main( int argc, char* argv[] ) { - // const uint16_t SCREEN_HEIGHT = 600; - // const uint16_t SCREEN_WIDTH = 800; - - // GameState state = Uninitialised; - // Initialise Logger& logger = Logger::instance(); - // SaveManager saveManager; - // state = Initialise; - - // ConfigParser userSettings = ConfigParser::UserSettings(); - - // EntityManager entityManager; // Seed the random number generator srand(static_cast<unsigned int>(time(nullptr))); - // std::vector< Entity* > entities; - // Genrate a Random chunk - // WorldHex2D map( 5 ); - //Chunk* chunk = new Chunk( 0, 0, 0); - //std::cout << chunk.getString() << std::endl; - // Chunk* chunk = map.getMidChunk(); - // std::cout << chunk->getString() << std::endl; - // map.showChunk( 0, 0, 0 ); - // map.moveInto( -2, 1, 1 ); - // map.moveInto( -3, 2, 1 ); - // map.moveInto( 5, -2, -3 )->visualise(); - // map.visualise(); - - // Menu Loop - - // List Saves - // saveManager.list(); - GameEngine* game = new GameEngine(); game->run(); - // userSettings.set( "exit", "teset" ); - // std::cout << userSettings; - - // Clean-up - // while( entities.size() > 0 ) - // { - // Entity* entity = entities.back(); - // entities.pop_back(); - // delete entity; - // } delete game; // Return -- GitLab