diff --git a/src/config.h b/src/config.h index a292354..ee7abe6 100644 --- a/src/config.h +++ b/src/config.h @@ -19,6 +19,7 @@ // FPS #define FRAME_RATE 60 #define FRAME_TIME sf::Time(sf::seconds(1.0f / FRAME_RATE)) +#define FRAME_LIMIT_ENABLED false // Window settings #define ANTIALIASINGLEVEL 8 diff --git a/src/game/game_factory.cpp b/src/game/game_factory.cpp index 30b5104..53efe7e 100644 --- a/src/game/game_factory.cpp +++ b/src/game/game_factory.cpp @@ -3,7 +3,8 @@ #include "../config.h" -std::shared_ptr GameFactory::createWindowed(const std::string &title, int width, int height) { +std::shared_ptr GameFactory::createWindowed(const std::string &title, int width, int height) +{ auto window = std::make_shared(sf::VideoMode(width, height), title, sf::Style::Default, getAdditionalSettings()); @@ -11,13 +12,16 @@ std::shared_ptr GameFactory::createWindowed(const std::string &title, int return Game::constructInstance(window); } -std::shared_ptr GameFactory::createFullscreen(const std::string &title) { +std::shared_ptr GameFactory::createFullscreen(const std::string &title) +{ sf::VideoMode fullScreenMode; auto availableModes = sf::VideoMode::getFullscreenModes(); - if (availableModes.empty()) { + if (availableModes.empty()) + { LOG(INFO) << "No fullscreen modes available, falling back to Desktop Mode."; fullScreenMode = sf::VideoMode::getDesktopMode(); - } else { + } else + { fullScreenMode = availableModes[0]; fullScreenMode.bitsPerPixel = sf::VideoMode::getDesktopMode().bitsPerPixel; } @@ -30,7 +34,8 @@ std::shared_ptr GameFactory::createFullscreen(const std::string &title) { return Game::constructInstance(window); } -sf::ContextSettings GameFactory::getAdditionalSettings() { +sf::ContextSettings GameFactory::getAdditionalSettings() +{ sf::ContextSettings settings = sf::ContextSettings(); settings.antialiasingLevel = ANTIALIASINGLEVEL; @@ -38,7 +43,11 @@ sf::ContextSettings GameFactory::getAdditionalSettings() { return settings; } -void GameFactory::applyAdditionalWindowConfig(sf::RenderWindow *window) { -// window->setFramerateLimit(FRAME_RATE); +void GameFactory::applyAdditionalWindowConfig(sf::RenderWindow *window) +{ + if (FRAME_LIMIT_ENABLED) + { + window->setFramerateLimit(FRAME_RATE); + } window->setKeyRepeatEnabled(KEY_REPEAT_ENABLED); }