-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdice_game.h
67 lines (50 loc) · 1.34 KB
/
dice_game.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
#ifndef __DICE_GAME
#define __DICE_GAME
#include "display.h"
#include "controller.h"
#include "input_processor.h"
#include "graphics.h"
struct Obstacles {
int rows[10][5];
int first_row = 0;
int num_displayed = 0;
Obstacles();
void fill_row(int row);
bool descend();
void recycle_lowest_row();
void resolve_collision(int column, int projectile_color);
int row_to_index(int row);
void draw(Display& disp);
};
struct Projectile {
int x; //0-4, on the grid. -1 signifies a non-existent projectile
int y;
int color;
bool draw(Display& disp);
Projectile();
Projectile(int x, int y, int color);
};
struct Projectiles {
Projectile projectile_list[5];
void add_projectile(int x, int y, int color);
void remove_projectile(int index);
void ascend_all();
void draw(Display& disp, Obstacles& obstacles);
Projectiles();
};
class DiceGame: public InputProcessor {
public:
Display& disp;
Controller *controllers;
int controller_count;
DiceGame(Display& disp, Controller *controllers, uint8_t controller_count);
bool play();
private:
bool handle_button_down(Controller::Button button, uint8_t controller_index);
bool paused;
Obstacles obstacles;
Projectiles projectiles;
Projectile player; //turns out the player has the exact same attributes as a projectile. Can change later
void draw_dice();
};
#endif