forked from odaki/TWANG
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Spawner.h
46 lines (39 loc) · 904 Bytes
/
Spawner.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
#include "Arduino.h"
#include <stdint.h> // uint8_t type variables
/*
A spawn pool is a point which spawns enemies forever
position: 0 to 1000 (start position on the strip)
rate: milliseconds between spawns, 1000 = 1 second
speed: speed of the enemies it spawns
direction: 0=towards start, 1=away from start
*/
class Spawner
{
public:
void Spawn(int pos, int rate, uint8_t speed, bool dir, long activate);
void Kill();
bool Alive();
int _pos;
int _rate;
uint8_t _speed;
bool _dir;
long _lastSpawned;
long _activate;
private:
bool _alive;
};
void Spawner::Spawn(int pos, int rate, uint8_t speed, bool dir, long activate){
_pos = pos;
_rate = rate;
_speed = speed;
_dir = dir;
_activate = millis()+activate;
_alive = 1;
}
void Spawner::Kill(){
_alive = 0;
_lastSpawned = 0;
}
bool Spawner::Alive(){
return _alive;
}