-
Notifications
You must be signed in to change notification settings - Fork 1
/
variables.h
143 lines (134 loc) · 3.59 KB
/
variables.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
#ifndef VARIABLES_H
#define VARIABLES_H
// Define maximum amount of particles.
#define MAXBULLETS 50
#define MAXSTARS 25
#define MAXENEMIES 5
#define MAXSUPPLY 3
// Define Movements
#define MOVE_UP 0
#define MOVE_UPLEFT 7
#define MOVE_LEFT 6
#define MOVE_DOWNLEFT 5
#define MOVE_DOWN 4
#define MOVE_DOWNRIGHT 3
#define MOVE_RIGHT 2
#define MOVE_UPRIGHT 1
// For the highscore
#define EEPROM_START_C1 EEPROM_STORAGE_SPACE_START
#define EEPROM_START_C2 EEPROM_START_C1 + 1
#define EEPROM_SCORE EEPROM_START_C1 + 2
typedef struct
{
// All coordinates are the upper right corner of an image.
byte x;
byte y;
byte height;
byte width;
unsigned int score;
byte destroyedShips;
byte lives;
bool alive;
// set invincible to 1 and then every two second a right-shift until
// invincible is zero.
// This way you are 2 seconds invincible. Or more, if you set
// invincible to 2, 4 or 8.
byte invincible;
byte bulletType;
byte bulletSpeed;
// The player cannot fire infinite bullets (and therefore stun the enemy).
byte bullets;
byte maxBullets;
// 0 is normal
// 1 is two at once
// 2 is one straight and two up/down diagonal
// 3 is two in the middle in addition
// 4 is two more diagonal
byte firetype;
byte speed; // Higher is better.
byte cooldown; // Shoot if cooldown == 0;
byte fireSpeed; // The lower, the faster you can fire.
byte lifepoints;
} Player;
typedef struct
{
byte x;
byte y;
} Star;
typedef struct
{
// All coordinates are the upper right corner of an image.
byte x;
byte y;
byte height;
byte width;
// Each number is a placeholder for different ships. These types define
// the image, bullettype and speed. The highest 1 indicates the type
// e.g. 0100 is the same type as 0111 or 0101 or 0110.
byte shipType;
byte speed; // Lower is better. Depends on current frame
byte lifepoints;
bool alive;
// Each number is a placeholder for another movement, e.g. straight-forward
// or sine. Needs to be implemented.
byte movement;
byte direction;
// If true, create a random supply after destruction.
bool supply;
byte tick; // Used for altering the direction.
} Enemy;
typedef struct
{
// All coordinates are the upper right corner of an image.
byte x;
byte y;
byte height;
byte width;
// byte appearance; // Currently only one appearance there.
byte damage;
byte speed;
bool alive;
bool playersBullet;
// Directions:
// 7 0 1
// 6 enemy 2
// 5 4 3
byte direction;
} Bullet;
typedef struct
{
byte x;
byte y;
bool alive;
} Supply;
typedef struct
{
byte x;
byte y;
byte tick; // Each tick is part of a different animation
} Explosion;
// Counter the frames. Every 60 frames is one second. This can be used for
// measuring time.
extern byte frameCounter;
// The stars in the background are saved here.
extern Star stars[MAXSTARS];
extern byte numberOfStars;
extern byte SCREEN_HEIGHT;
extern byte SCREEN_WIDTH;
extern Player player;
extern Arduboy2 arduboy;
extern Enemy enemies[MAXENEMIES];
extern byte numberOfEnemies;
extern Bullet bullets[MAXBULLETS];
extern byte numberOfBullets;
extern Supply supplies[MAXSUPPLY];
extern byte noOfSupplies;
extern bool gameStarted;
extern Explosion explosions[MAXENEMIES+1];
extern bool boss_coming;
extern byte extra_tick;
extern unsigned int high_score;
// Following is a bit ugly, hence I deactivated it.
// extern byte which_extra;
extern byte last_boss;
#endif