diff --git a/src/DebugOverlay.cpp b/src/DebugOverlay.cpp index b994129..2f0fcd5 100644 --- a/src/DebugOverlay.cpp +++ b/src/DebugOverlay.cpp @@ -21,7 +21,7 @@ DebugOverlay::DebugOverlay(const std::string &fontPath) void DebugOverlay::update(const int drawCalls, const float timeScale, const sf::RenderWindow &window, - const size_t threadCount, + const size_t threadCount, const size_t totalBalls, const size_t ballsPerThread) { const float frameTime = m_fpsClock.restart().asSeconds(); @@ -54,7 +54,9 @@ void DebugOverlay::update(const int drawCalls, const float timeScale, oss << "Mouse: " << mousePos.x << ", " << mousePos.y << "\n"; oss << "Time scale: " << timeScale << "\n"; oss << "\nThreads: " << threadCount; - oss << "\nBalls per thread: " << ballsPerThread; + oss << "\nBalls per thread: " << ballsPerThread << "\n"; + + oss << "\nTotal Balls: " << totalBalls; m_text.setString(oss.str()); } diff --git a/src/DebugOverlay.hpp b/src/DebugOverlay.hpp index 8d6beba..5f518ac 100644 --- a/src/DebugOverlay.hpp +++ b/src/DebugOverlay.hpp @@ -10,7 +10,7 @@ class DebugOverlay { explicit DebugOverlay(const std::string &fontPath); void update(int drawCalls, float timeScale, const sf::RenderWindow &window, - size_t threadCount, size_t ballsPerThread); + size_t threadCount, size_t totalBalls, size_t ballsPerThread); void draw(sf::RenderWindow &window) const; diff --git a/src/Game.cpp b/src/Game.cpp index ca78587..4516d43 100644 --- a/src/Game.cpp +++ b/src/Game.cpp @@ -36,6 +36,7 @@ Game::Game() } void Game::processKeyPressed(const sf::Event::KeyPressed &keyPressed) { + const auto mousePos = sf::Mouse::getPosition(m_window); switch (keyPressed.code) { case sf::Keyboard::Key::Equal: m_timeScale = std::min(10.0f, m_timeScale + 0.25f); @@ -48,6 +49,11 @@ void Game::processKeyPressed(const sf::Event::KeyPressed &keyPressed) { break; case sf::Keyboard::Key::Delete: if (!m_objects.empty()) m_objects.pop_back(); + break; + case sf::Keyboard::Key::Insert: + spawnBall(sf::Vector2f(static_cast(mousePos.x), + static_cast(mousePos.y))); + break; default: break; } @@ -224,7 +230,7 @@ void Game::render() { const size_t threadCount = m_threadPool.getThreadCount(); const size_t ballsPerThread = m_objects.size() / threadCount; m_debugOverlay.update(m_drawCallCount + 2, m_timeScale, m_window, - threadCount, ballsPerThread); + threadCount, m_objects.size(), ballsPerThread); m_debugOverlay.draw(m_window); }