diff --git a/src/GameEngine.cpp b/src/GameEngine.cpp index f023a17..5fa7861 100644 --- a/src/GameEngine.cpp +++ b/src/GameEngine.cpp @@ -11,7 +11,8 @@ GameEngine::GameEngine() { Resources::font.loadFromFile("./assets/JetbrainsMono.ttf"); Resources::game = this; - window.create(sf::VideoMode(1024, 768), "McRogueFace - r/RoguelikeDev Tutorial Run"); + window_title = "McRogueFace - r/RoguelikeDev Tutorial Run"; + window.create(sf::VideoMode(1024, 768), window_title); visible = window.getDefaultView(); window.setFramerateLimit(30); scene = "uitest"; @@ -44,6 +45,7 @@ sf::RenderWindow & GameEngine::getWindow() { return window; } void GameEngine::run() { + float fps = 0.0; clock.restart(); while (running) { @@ -55,6 +57,8 @@ void GameEngine::run() currentScene()->sRender(); currentFrame++; frameTime = clock.restart().asSeconds(); + fps = 1 / frameTime; + window.setTitle(window_title + " " + std::to_string(fps) + " FPS"); } } diff --git a/src/GameEngine.h b/src/GameEngine.h index 35e479a..cce4d3c 100644 --- a/src/GameEngine.h +++ b/src/GameEngine.h @@ -19,6 +19,7 @@ class GameEngine sf::View visible; sf::Clock clock; float frameTime; + std::string window_title; public: GameEngine();