blob: c85dd9e46738156f87b6d11a00591ec9b810c022 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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() {
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);
}
}
}
}
|