From 6fffbbed46b903223f752faee7bbb870557665c9 Mon Sep 17 00:00:00 2001 From: fschildt Date: Thu, 11 Dec 2025 02:26:56 +0100 Subject: refactor Game.hpp, add unfinished pong --- src/games/pong/Pong.hpp | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 src/games/pong/Pong.hpp (limited to 'src/games/pong/Pong.hpp') diff --git a/src/games/pong/Pong.hpp b/src/games/pong/Pong.hpp new file mode 100644 index 0000000..ec6145b --- /dev/null +++ b/src/games/pong/Pong.hpp @@ -0,0 +1,42 @@ +#pragma once + +#include "games/Game.hpp" +#include "common/shapes.hpp" + + +class Pong : public Game { + enum PaddleDirection { + NONE = 0, + UP = 1, + DOWN = -1 + }; + + struct Paddle { + float y; + PaddleDirection dir; + }; + + struct Ball { + Circle circle; + V2F32 velocity; + }; + + static constexpr float PADDLE_HEIGHT = 0.5f; + static constexpr float PADDLE_WIDTH = 0.2f; + static constexpr float PADDLE_SPEED = 1.0f; + +private: + void Start() override; + void ProcessEvent(SDL_Event& event) override; + void FinishUpdate(float dt) override; + void Draw() override; + +private: + void MovePaddle(Paddle& paddle, float dt); + void MoveBall(float dt); + +private: + Paddle m_paddles[2]; + Ball m_ball; +}; + -- cgit v1.2.3