diff --git a/GameWorld.cpp b/GameWorld.cpp index e69de29..352154d 100644 --- a/GameWorld.cpp +++ b/GameWorld.cpp @@ -0,0 +1,23 @@ +#include "GameWorld.h" +#include "InputManager.h" + +namespace ZL { + GameWorld& GameWorld::getInstance() { + static GameWorld instance; + return instance; + } + + void GameWorld::update(float deltaTime) { + auto& input = InputManager::getInstance(); + + // Update game state based on input + if (input.isKeyPressed(SDL_SCANCODE_W)) { + // Move forward + } + // ... handle other game logic ... + } + + void GameWorld::addObject(const Vector3f& position) { + mGameObjects.push_back(position); + } +} diff --git a/GameWorld.h b/GameWorld.h index e69de29..475acd9 100644 --- a/GameWorld.h +++ b/GameWorld.h @@ -0,0 +1,18 @@ +#pragma once +#include "Vector3f.h" +#include +#include + +namespace ZL { + class GameWorld { + public: + static GameWorld& getInstance(); + void update(float deltaTime); + void addObject(const Vector3f& position); + // ...other game world related methods... + + private: + GameWorld() = default; + std::vector mGameObjects; + }; +} diff --git a/InputManager.cpp b/InputManager.cpp index e69de29..0addbde 100644 --- a/InputManager.cpp +++ b/InputManager.cpp @@ -0,0 +1,27 @@ +#include "InputManager.h" + +namespace ZL { + InputManager& InputManager::getInstance() { + static InputManager instance; + return instance; + } + + void InputManager::processInput() { + SDL_Event event; + while (SDL_PollEvent(&event)) { + if (event.type == SDL_QUIT) { + mShouldQuit = true; + } + else if (event.type == SDL_KEYDOWN) { + mKeys[event.key.keysym.scancode] = true; + } + else if (event.type == SDL_KEYUP) { + mKeys[event.key.keysym.scancode] = false; + } + } + } + + bool InputManager::isKeyPressed(SDL_Scancode key) const { + return mKeys[key]; + } +} diff --git a/InputManager.h b/InputManager.h index e69de29..035ff06 100644 --- a/InputManager.h +++ b/InputManager.h @@ -0,0 +1,17 @@ +#pragma once +#include + +namespace ZL { + class InputManager { + public: + static InputManager& getInstance(); + void processInput(); + bool isKeyPressed(SDL_Scancode key) const; + bool shouldQuit() const { return mShouldQuit; } + + private: + InputManager() = default; + bool mKeys[SDL_NUM_SCANCODES] = {false}; + bool mShouldQuit = false; + }; +} diff --git a/main.cpp b/main.cpp index 89566be..6de058a 100755 --- a/main.cpp +++ b/main.cpp @@ -413,7 +413,9 @@ namespace ZL // std::cout << "Before removal:\n"; ZL::PrintInventory(); - + 21s  +    ~/g/ZeptoLabTest1    Albert ⇣2 +5  git commit -m "added sh file for start in linux" + [Albert 666bfc1] added sh file for start in linux // Удаляем "Cone" из инвентаря // ZL::RemoveItemFromInventory("Cone"); @@ -534,7 +536,9 @@ namespace ZL case SDLK_w: Env::upPressed = false; break; - case SDLK_DOWN: + case SDLK_DOWN: 21s  +    ~/g/ZeptoLabTest1    Albert ⇣2 +5  git commit -m "added sh file for start in linux" + [Albert 666bfc1] added sh file for start in linux case SDLK_s: Env::downPressed = false; break;