aboutsummaryrefslogtreecommitdiff
path: root/src/games/pong/Pong.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/games/pong/Pong.hpp')
-rw-r--r--src/games/pong/Pong.hpp42
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;
+};
+