diff --git a/src/core/CoreData.h b/src/core/CoreData.h index c219609..1d65769 100644 --- a/src/core/CoreData.h +++ b/src/core/CoreData.h @@ -2,8 +2,9 @@ #include "ui/managers/debug/DebugData.h" #include "input/InputState.h" - +#include "scenes/base/SceneEvent.h" struct CoreData { DebugData debugData; InputState inputState; + SceneType sceneType = SceneType::MainMenuScene; }; \ No newline at end of file diff --git a/src/core/GameApplication.cpp b/src/core/GameApplication.cpp index 365a1e2..84ba3fe 100644 --- a/src/core/GameApplication.cpp +++ b/src/core/GameApplication.cpp @@ -31,7 +31,7 @@ bool GameApplication::initialize() { // 输入管理 - m_inputManager = std::make_unique(m_coreData.inputState); + m_inputManager = std::make_unique(m_coreData); // 窗口管理 m_windowManager = std::make_unique(); diff --git a/src/input/InputManager.cpp b/src/input/InputManager.cpp index e8163e9..422d3ae 100644 --- a/src/input/InputManager.cpp +++ b/src/input/InputManager.cpp @@ -1,7 +1,8 @@ #include "InputManager.h" -InputManager::InputManager(InputState& inputState) : - m_currentInputState(inputState) +InputManager::InputManager(CoreData& coreData) : + m_currentInputState(coreData.inputState), + m_coreData(coreData) { } @@ -31,10 +32,49 @@ SDL_AppResult InputManager::handleInputEvent(const SDL_Event* event) { static_cast(event->motion.y)}; break; case SDL_EVENT_KEY_DOWN: - if (event->key.key == SDLK_F11) { - m_currentInputState.isFullscreen = !m_currentInputState.isFullscreen; + switch(event->key.key) { + case SDLK_F11: + m_currentInputState.isFullscreen = !m_currentInputState.isFullscreen; + break; + case SDLK_B: + if (m_coreData.sceneType == SceneType::MainMenuScene) { + m_isStartBadApple = true; + m_badapple.push_back('b'); + } + + break; + case SDLK_A: + if (m_isStartBadApple) { + m_badapple.push_back('a'); + } + break; + case SDLK_D: + if (m_isStartBadApple) { + m_badapple.push_back('d'); + } + break; + case SDLK_P: + if (m_isStartBadApple) { + m_badapple.push_back('p'); + } + break; + case SDLK_L: + if (m_isStartBadApple) { + m_badapple.push_back('l'); + } + break; + case SDLK_E: + if (m_isStartBadApple) { + m_badapple.push_back('e'); + if (m_badapple == "badapple") { + m_currentInputState.isBadApplePress = true; + } + m_badapple.clear(); + } + break; } break; + } return SDL_APP_CONTINUE; } diff --git a/src/input/InputManager.h b/src/input/InputManager.h index 9934791..cedd9a6 100644 --- a/src/input/InputManager.h +++ b/src/input/InputManager.h @@ -1,14 +1,18 @@ #pragma once #include - +#include "core/CoreData.h" #include "InputState.h" class InputManager { public: - InputManager(InputState& inputState); + InputManager(CoreData& coreData); SDL_AppResult handleInputEvent(const SDL_Event* event); InputState GetInputState() const; private: InputState& m_currentInputState; + CoreData& m_coreData; + bool m_isStartBadApple = false; + + std::string m_badapple; // 彩蛋 }; \ No newline at end of file diff --git a/src/input/InputState.h b/src/input/InputState.h index 73f6a52..7c9f7fc 100644 --- a/src/input/InputState.h +++ b/src/input/InputState.h @@ -1,6 +1,7 @@ #pragma once #include #include +#include struct InputState { glm::vec2 mouseCilckOn; @@ -8,4 +9,5 @@ struct InputState glm::vec2 mouseCurrentPosition; glm::ivec2 mouseCurrentLogicalPosition; bool isFullscreen = false; + bool isBadApplePress = false; };