diff --git a/include/Game.h b/include/Game.h index 15af3b3..1ae163c 100644 --- a/include/Game.h +++ b/include/Game.h @@ -45,10 +45,11 @@ struct Player class Game { public: - Game(); + Game() = delete; + + Game(bool useImgui_in); void run(); - void runNoImgui(); private: void imgui(); @@ -118,5 +119,6 @@ private: Color brickColor{}; Color playerColor{}; Color specialBrickColor{}; + bool useImgui; static constexpr unsigned int numPhysicsUpdates{4}; }; \ No newline at end of file diff --git a/src/Game.cpp b/src/Game.cpp index 426b20e..e6ade1f 100644 --- a/src/Game.cpp +++ b/src/Game.cpp @@ -25,7 +25,7 @@ Player::Player(sf::Vector2f position_in) { } -Game::Game() +Game::Game(bool useImgui_in) : window({sf::VideoMode({ 1920u, 1080u }), "project-breakout"}) , font("assets/fonts/ChakraPetch-Regular.ttf") , lives(font) @@ -38,6 +38,7 @@ Game::Game() , brickBreakSound(brickBreakSoundBuffer) , failSound(failSoundBuffer) , volume(10) + , useImgui(useImgui_in) { if (!ImGui::SFML::Init(window)) return; @@ -664,39 +665,13 @@ void Game::run() checkEndGame(); - imgui(); - - render(); - - } - - ImGui::SFML::Shutdown(); -} - -void Game::runNoImgui() -{ - while(window.isOpen()) - { - ImGui::SFML::Update(window, clock.restart()); - - input(); - - for (size_t i = 0; i <= numPhysicsUpdates; i++) + if (useImgui) { - updateEntities(); - - movement(); - - collision(); - - soundSystem(); - - scoreSystem(); + imgui(); } - checkEndGame(); - render(); + } ImGui::SFML::Shutdown(); diff --git a/src/main.cpp b/src/main.cpp index e8b7ca7..421025f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2,7 +2,6 @@ int main(int argc, char* argv[]) { - Game game; // parse command-line arguments bool useImgui{true}; @@ -14,12 +13,8 @@ int main(int argc, char* argv[]) } } - if (useImgui) - { + Game game(useImgui); + game.run(); - } - else - { - game.runNoImgui(); - } + } \ No newline at end of file