diff options
Diffstat (limited to 'source/App.cpp')
-rw-r--r-- | source/App.cpp | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/source/App.cpp b/source/App.cpp index 35fb5f7..c85dd9e 100644 --- a/source/App.cpp +++ b/source/App.cpp @@ -1,7 +1,35 @@ #include "App.hpp" #include <imgui.h> +#include <memory> + +void App::Init() { + mCurrentWorld = std::make_unique<GameWorld>(); + auto worldRoot = mCurrentWorld->GetRoot(); + + constexpr int kPlayerCount = 2; + for (int i = 0; i < kPlayerCount; ++i) { + auto player = new Player(mCurrentWorld.get()); + worldRoot.AddChild(player); + mPlayers.push_back(player); + } +} + +void App::Shutdown() { + mCurrentWorld = nullptr; + mPlayers.clear(); +} void App::Show() { - // Application goes here + mCurrentWorld->Draw(); +} + +void App::HandleKey(GLFWkeyboard* keyboard, int key, int action) { + for (auto& player : mPlayers) { + for (auto playerKeyboard : player->boundKeyboards) { + if (playerKeyboard == keyboard) { + player->HandleKeyInput(key, action); + } + } + } } |