mirror of
https://github.com/zhenyan121/SporeBG-Conid.git
synced 2026-04-10 06:14:08 +08:00
Use GameApplication to cnotrol game
This commit is contained in:
@@ -1,16 +1,35 @@
|
||||
#include "GameApplication.h"
|
||||
|
||||
GameApplication::GameApplication() {
|
||||
m_gameSession = std::make_unique<GameSession>();
|
||||
m_inputManager = std::make_unique<InputManager>();
|
||||
|
||||
}
|
||||
|
||||
GameApplication::~GameApplication() {
|
||||
|
||||
}
|
||||
|
||||
bool GameApplication::initialize() {
|
||||
m_gameSession->initialize();
|
||||
m_inputManager = std::make_unique<InputManager>();
|
||||
m_windowManager = std::make_unique<WindowManager>();
|
||||
|
||||
m_windowManager->Initialize(m_config);
|
||||
m_sceneManager = std::make_unique<SceneManager>(m_windowManager->GetRenderer());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
SDL_AppResult GameApplication::handleInputEvent(SDL_Event* event) {
|
||||
|
||||
auto result = m_inputManager->handleInputEvent(event);
|
||||
// 只有当事件是鼠标左键按下时,才触发点击逻辑
|
||||
if (event->type == SDL_EVENT_MOUSE_BUTTON_DOWN &&
|
||||
event->button.button == SDL_BUTTON_LEFT) {
|
||||
InputState input = m_inputManager->GetInputState();
|
||||
m_sceneManager->handleClickCurrent(input.mouseCilckOn);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void GameApplication::run() {
|
||||
m_sceneManager->updateCurrent();
|
||||
m_sceneManager->renderCurrent();
|
||||
}
|
||||
Reference in New Issue
Block a user