blob: 22d271ee662e3c73edd71988746c8adb032cf529 (
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
49
50
51
52
53
54
55
56
|
#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();
private:
void Start() override;
void ProcessEvent(SDL_Event& event) override;
void FinishUpdate(float dt) override;
void Draw() override;
void DrawGameOverMenu() override;
uint32_t GetSoftdropCount(float dt);
void HandleTetrominoPlacement();
int32_t ReadHighscore();
void WriteHighscore();
void DrawLineCounter();
void DrawStatistics();
void DrawScore();
void DrawNextTetromino();
void DrawLevel();
private:
static constexpr Color s_text_color {0.9f, 0.9f, 0.9f, 1.0f};
static constexpr size_t s_frame_strings_capacity {32};
static constexpr char s_tetris_highscore_path[]{"tetris_highscore.txt"};
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;
};
|