diff options
| author | fschildt <florian.schildt@protonmail.com> | 2025-12-11 02:26:56 +0100 |
|---|---|---|
| committer | fschildt <florian.schildt@protonmail.com> | 2025-12-11 02:56:04 +0100 |
| commit | 6fffbbed46b903223f752faee7bbb870557665c9 (patch) | |
| tree | 11c52ccd5fc3a6e3bae142052fa54c49bc6ba853 /src/games/pong/Pong.hpp | |
| parent | 69f46d34e9c6a25c63668423fd984d07c1f099a3 (diff) | |
refactor Game.hpp, add unfinished pong
Diffstat (limited to 'src/games/pong/Pong.hpp')
| -rw-r--r-- | src/games/pong/Pong.hpp | 42 |
1 files changed, 42 insertions, 0 deletions
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; +}; + |
