blob: 03966fd42e4598fe5fbf53541f7c03c55e4eb7cd (
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
46
47
48
|
#pragma once
#include <games/Game.hpp>
#include <games/tetris/Tetromino.hpp>
#include <games/tetris/Board.hpp>
#include <common/Font.hpp>
class Tetris : public Game {
public:
Tetris();
bool Update(std::vector<SDL_Event>& events) override;
private:
void Start();
void UpdateResumeState(SDL_Event& event);
void UpdatePauseState(SDL_Event& event);
uint32_t GetSoftdropCount(float dt);
void HandleTetrominoPlacement();
void HandleGameOver();
void Draw();
void DrawLineCounter();
void DrawStatistics();
void DrawScore();
void DrawNextTetromino();
void DrawLevel();
void DrawGameOverMenu();
private:
Font m_font;
Board m_board;
Tetromino m_active_tetromino;
Tetromino::Id m_next_tetromino_id;
int32_t m_tetromino_counters[Tetromino::id_count] {};
int32_t m_score = 0;
int32_t m_line_counter = 0;
int32_t m_starting_level = 0;
int32_t m_level = 0;
int32_t m_softdrop_counter = 0;
int32_t m_highscore = 0;
};
|