streamline the way command line arguments are used
This commit is contained in:
parent
cdda33f786
commit
cb31a38427
|
|
@ -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};
|
||||
};
|
||||
35
src/Game.cpp
35
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,7 +665,10 @@ void Game::run()
|
|||
|
||||
checkEndGame();
|
||||
|
||||
if (useImgui)
|
||||
{
|
||||
imgui();
|
||||
}
|
||||
|
||||
render();
|
||||
|
||||
|
|
@ -672,32 +676,3 @@ void Game::run()
|
|||
|
||||
ImGui::SFML::Shutdown();
|
||||
}
|
||||
|
||||
void Game::runNoImgui()
|
||||
{
|
||||
while(window.isOpen())
|
||||
{
|
||||
ImGui::SFML::Update(window, clock.restart());
|
||||
|
||||
input();
|
||||
|
||||
for (size_t i = 0; i <= numPhysicsUpdates; i++)
|
||||
{
|
||||
updateEntities();
|
||||
|
||||
movement();
|
||||
|
||||
collision();
|
||||
|
||||
soundSystem();
|
||||
|
||||
scoreSystem();
|
||||
}
|
||||
|
||||
checkEndGame();
|
||||
|
||||
render();
|
||||
}
|
||||
|
||||
ImGui::SFML::Shutdown();
|
||||
}
|
||||
11
src/main.cpp
11
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();
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue