#pragma once #include #include #include #include "GameState.h" #include "Graphics.h" #include "components/GraphicsComponent.h" #include "components/InputComponent.h" constexpr int HORIZONTAL_SPEED = 10; class GameObject { public: GameObject( std::unique_ptr graphics, std::unique_ptr input) : m_graphics(std::move(graphics)) , m_input(std::move(input)) { /* Intentionally empty */ } void update(Graphics &graphics) { if (m_input->moveUp) { speed.x = HORIZONTAL_SPEED; } m_graphics->update(graphics); } GameState processInput(SDL_Event const* event) { return m_input->update(event); } private: std::unique_ptr m_graphics; std::unique_ptr m_input; SDL_Point speed; };