diff options
Diffstat (limited to 'src/games/breakout/Breakout.hpp')
| -rw-r--r-- | src/games/breakout/Breakout.hpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/games/breakout/Breakout.hpp b/src/games/breakout/Breakout.hpp new file mode 100644 index 0000000..2b7c9b3 --- /dev/null +++ b/src/games/breakout/Breakout.hpp @@ -0,0 +1,45 @@ +#pragma once + +#include "games/Game.hpp" +#include "common/shapes.hpp" + + +class Breakout : public Game { + struct Paddle { + float x; + float dx; + }; + + struct Ball { + Circle circle; + float dx; + float dy; + }; + + static constexpr float MAP_WIDTH = 4.0f; + static constexpr float MAP_HEIGHT = 3.0f; + + static constexpr uint32_t BRICK_ROWS = 8; + static constexpr uint32_t BRICK_COLS = 14; + + static constexpr float PADDLE_HEIGHT = 0.1f; + static constexpr float PADDLE_WIDTH = 0.6f; + static constexpr float PADDLE_SPEED = 1.0f; + + +private: + void Start() override; + void ProcessEvent(SDL_Event& event) override; + void Update(float dt) override; + void Draw() override; + +private: + void MovePaddle(float dt); + void MoveBall(float dt); + +private: + Rectangle m_bricks[BRICK_ROWS][BRICK_COLS]; + Paddle m_paddle; + Ball m_ball; +}; + |
