-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgamestate.h
84 lines (64 loc) · 1.53 KB
/
gamestate.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
#ifndef GAMESTATE_H
#define GAMESTATE_H
#include "renderer.h"
#include "player.h"
#include "box.h"
#include "bullet.h"
#include "powerup.h"
#define BOX_SPAWN_TIMER 1.5f
#define BOX_COUNT_MAX 30
#define POWERUP_SPAWN_TIME_DEFAULT 8
#define POWERUP_SPAWN_TIME_VARIANCE 6
#define POWERUP_COUNT_MAX 10
#define BOX_SIZE_DEFAULT 6
#define BOX_SIZE_VARIANCE 10
#define BOX_SPEED_DEFAULT 60
#define BOX_SPEED_INCREASE 120
#define BOX_SPEED_VARIANCE_DEFAULT 10
#define BOX_SPEED_VARIANCE_INCREASE 40
#define BULLET_COUNT_MAX 100
#define MAX_DIFFICULTY_TIME 80.f
typedef struct game_state {
graphics_t *device;
vector2_t area;
float delta;
player_t *player;
box_t *boxes;
bullet_t *bullets;
powerup_t *powerups;
int boxes_count;
int bullets_count;
int powerups_count;
int player_count;
int frames_count;
int fps;
float difficulty; /* increases with time */
/* Scene & Game Timers */
float time;
float timer_frame;
float timer_box;
float timer_game;
float timer_powerup;
float powerup_wait; /* time before next power-up spawns */
/* IO */
int p1_left_down;
int p1_right_down;
int p1_left_clicked;
int p1_right_clicked;
int p1_left_held;
int p1_right_held;
int p1_left_released;
int p1_right_released;
float p1_left_debounce_timer;
float p1_right_debounce_timer;
} game_state_t;
typedef struct scene {
/* Functions */
void (*init)(game_state_t *state);
int (*update)(game_state_t *state);
void (*draw)(game_state_t *state);
void (*free)(game_state_t *state);
/* Transition */
struct scene *next_scene;
} scene_t;
#endif