-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstate_init.cpp
More file actions
75 lines (68 loc) · 1.76 KB
/
state_init.cpp
File metadata and controls
75 lines (68 loc) · 1.76 KB
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
#include "include/globals.h"
#include "include/state_init.h"
#include <cassert>
GameState new_game_state() {
GameState game;
game.score = 0;
game.status = PLAYING;
game.terrain;
game.paddle = new_paddle();
game.balls = {};
game.particles = {};
return game;
}
void reset_game_state(GameState& game) {
game.score = 0;
game.status = PLAYING;
game.terrain.clear();
game.paddle = new_paddle();
game.balls = {};
game.particles = {};
}
Paddle new_paddle() {
Paddle paddle;
paddle.x = WINDOW_WIDTH / 2;
paddle.y = WINDOW_HEIGHT - 50;
paddle.width = 100;
paddle.height = 10;
paddle.clr = clr_paddle;
return paddle;
}
Particle new_particle(point_2d pos, vector_2d vel, color clr, int size, int ttl) {
Particle particle;
particle.pos = pos;
particle.vel = vel;
particle.size = size;
particle.clr = clr;
particle.ttl = ttl;
particle.max_ttl = ttl;
particle.original_size = size;
return particle;
}
Ball new_ball(point_2d pos, vector_2d vel, int size, color clr, BallEffect effect, int ttl_type, int ttl) {
Ball ball;
ball.pos = pos;
ball.vel = vel;
ball.size = size;
ball.clr = clr;
ball.effect = effect;
ball.active = true;
ball.trail = {};
ball.ttl_type = ttl_type;
ball.ttl = ttl;
ball.max_ttl = ttl;
assert(effect && "BallEffect must be initialized with a valid function");
return ball;
}
Block new_block(point_2d pos, point_2d target_pos, ivec2 grid_pos, int width, int height, color c) {
Block block;
block.pos = pos;
block.target_pos = target_pos;
block.grid_pos = grid_pos;
block.width = width;
block.height = height;
block.clr = c;
block.active = true;
block.y_vel = 0.0;
return block;
}