-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgame_state.h
75 lines (66 loc) · 1.31 KB
/
game_state.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
#ifndef _GAMESTATE_H_
#define _GAMESTATE_H_
#define PI ((double)3.1415926)
#define STARTING_HEALTH 100
#define ROTATE_INCREMENT 3
#define SHIP_RADIUS 15
#define SHIP_WIDTH 8
#define SHIP_TUCK 3
#define SHIP_THRUST 0.06
#define SHIP_MAX_THRUST 4.0
#define SHIP_BREAK_SPEED 0.6
#define BULLET_SPEED 5
#define MAX_BULLETS 30
#define BULLET_COOLDOWN 8
#define BULLET_DAMAGE 10
#define MAX_SHIPS 4
enum INPUT
{
INPUT_thrust = (1 << 0),
INPUT_break = (1 << 1),
INPUT_rotate_left = (1 << 2),
INPUT_rotate_right = (1 << 3),
INPUT_fire = (1 << 4),
INPUT_bomb = (1 << 5),
};
typedef struct Position
{
double x, y;
} Position;
typedef struct Velocity
{
double dx, dy;
} Velocity;
typedef struct Bullet
{
int active;
Position position;
Velocity velocity;
} Bullet;
typedef struct Ship
{
Position position;
Velocity velocity;
int radius;
int heading;
int health;
int speed;
int cooldown;
Bullet bullets[MAX_BULLETS];
int score;
} Ship;
typedef struct Bounds
{
long left;
long top;
long right;
long bottom;
} Bounds;
typedef struct GameState
{
int frame_number;
Bounds bounds;
int num_ships;
Ship ships[MAX_SHIPS];
} GameState;
#endif // ifndef _GAMESTATE_H_