-
Notifications
You must be signed in to change notification settings - Fork 1
/
state_management.h
161 lines (137 loc) · 3.22 KB
/
state_management.h
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#pragma once
#include "types.h"
// GLOBAL
/**
* @brief Update the global state of the game.
*
* @param g The game state.
*/
void update_global_state(GameState& g);
// BLOCK
/**
* @brief Update the block's position.
*
* @param b The block to update.
* @param g The game state.
*/
void block_update(Block& b, GameState& g);
// TERRAIN
/**
* @brief Update the terrain in the game.
*
* @param g The game state.
*/
void update_terrain(GameState& g);
/**
* @brief Destroy the block.
*
* @param b The block to destroy.
* @param g The game state.
*/
void block_destroy(const Block& b, GameState& g);
//BALL
/**
* @brief Update the ball's position.
*
* @param b The ball to update.
* @param g The game state.
*/
void ball_update(Ball& b, GameState& g);
///**
// * @brief Destroy the ball.
// *
// * @param b The ball to destroy.
// * @param g The game state.
// */
//void ball_destroy(Ball& b, GameState& g);
/**
* @brief Check if the ball has collided with the screen edge.
*
* @param b The ball to check.
*/
void ball_check_wall_collision(Ball& b);
/**
* @brief Check if the ball has collided with a block.
*
* @param b The ball to check.
* @param g The game state.
*/
void ball_check_block_collision(Ball& b, GameState& g);
/**
* @brief Check if the ball has collided with the paddle.
*
* @param b The ball to check.
* @param g The game state.
*/
void ball_check_paddle_collision(Ball& b, GameState& g);
///**
// * @brief Update the particles in the ball's trail.
// *
// * @param b The ball to update the trail for.
// */
//void trail_update(Ball& b);
/**
* @brief Update the balls in the game.
*
* @param g The game state.
*/
void update_balls(GameState& g);
// PADDLE
/**
* @brief Update the paddle's position.
*
* @param g The game state.
*/
void paddle_update(GameState& g);
//
//
// PARTICLE
/**
* @brief Update the particle's position.
*
* @param p The particle to update.
*/
void particle_update(Particle& p);
/**
* @brief Update the particles in the game.
*
* @param g The game state.
*/
void update_particles(GameState& g);
/**
* @brief Count the number of non-empty rows in the terrain.
*
* @param g The game state.
* @return int The number of non-empty rows.
*/
int count_non_empty_rows(GameState& g);
/**
* @brief Shift the rows in the terrain down by the given number of rows.
*
* @param g The game state.
* @param num_rows_to_shift The number of rows to shift.
*/
void shift_rows_down(GameState& g, int num_rows_to_shift);
/**
* @brief Add a new chunk of terrain to the game.
*
* @param g The game state.
* @param num_rows The number of rows in the chunk.
*/
void add_new_chunk(GameState& g, int num_rows);
/**
* @brief Uses dfs_mark_reachable() to check if blocks are not connected to top row (have been shaved off main body of terrain)
* and deactivates them.
*
* @param g The game state.
*/
void deactivate_disconnected_clusters(GameState& g);
/**
* @brief Uses DFS to mark blocks that are reachable from the top row.
*
* @param g The game state.
* @param row The row to start the search from.
* @param col The column to start the search from.
* @param visited The visited array.
*/
void dfs_mark_reachable(GameState& g, int row, int col, std::vector<std::vector<bool>>& visited);