From 6da9be5810bf82e9d0b3b2a8bce7606ef2e2bf93 Mon Sep 17 00:00:00 2001 From: fschildt Date: Tue, 20 Jan 2026 01:22:45 +0100 Subject: breakout: delete pong, add breakout --- src/games/breakout/Breakout.hpp | 45 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 src/games/breakout/Breakout.hpp (limited to 'src/games/breakout/Breakout.hpp') 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; +}; + -- cgit v1.2.3