blob: 2b7c9b3fe82cb45f5272145d983fb43256e55b89 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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;
};
|