diff --git a/lib/include/chomper/runtimes/game.hpp b/lib/include/chomper/runtimes/game.hpp index 81c4d13..3769010 100644 --- a/lib/include/chomper/runtimes/game.hpp +++ b/lib/include/chomper/runtimes/game.hpp @@ -4,6 +4,7 @@ #include "chomper/runtime.hpp" #include "chomper/world.hpp" #include +#include #include #include @@ -39,5 +40,8 @@ class Game : public IRuntime, public klib::Pinned { std::unique_ptr m_player{}; std::unique_ptr m_world{}; + + le::drawable::Text m_countdownText{}; + kvf::Seconds m_countdown{3}; }; } // namespace chomper::runtime diff --git a/lib/src/runtimes/game.cpp b/lib/src/runtimes/game.cpp index 740158b..155c3b8 100644 --- a/lib/src/runtimes/game.cpp +++ b/lib/src/runtimes/game.cpp @@ -4,22 +4,35 @@ #include namespace chomper::runtime { +namespace { +constexpr auto countdownParams_v = le::drawable::Text::Params{ + .height = le::TextHeight{60}, +}; +} using ActionValue = le::input::action::Value; Game::Game(gsl::not_null engine) : m_engine(engine), m_mapping(&engine->getInputRouter()) { createPlayer(); m_world = std::make_unique(m_engine); + + m_countdownText.set_string(engine->getResources().getMainFont(), "3", countdownParams_v); } void Game::tick(kvf::Seconds const dt) { - m_player->tick(dt); - ImGui::SetNextWindowSize({300.0f, 300.0f}, ImGuiCond_Once); if (ImGui::Begin("Debug Inspect")) { debugInspectWindow(); } ImGui::End(); + if (m_countdown.count() > 0) { + m_countdown -= dt; + m_countdownText.set_string(m_engine->getResources().getMainFont(), std::format("{}", static_cast(m_countdown.count() + 1)), countdownParams_v); + return; + } + + m_player->tick(dt); + // On death if (!m_player->getInfo().alive) { m_engine->setNextRuntime(); @@ -29,6 +42,9 @@ void Game::tick(kvf::Seconds const dt) { void Game::render(le::IRenderer& renderer) const { m_world->draw(renderer); m_player->draw(renderer); + if (m_countdown.count() > 0) { + m_countdownText.draw(renderer); + } } void Game::debugInspectWindow() {