-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSpawnDirector.pde
82 lines (70 loc) · 1.22 KB
/
SpawnDirector.pde
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
public class SpawnDirector
{
private int spawnTimer = 0;
private int killTimer = 0;
private int killFrequency = 0;
private boolean canSpawn = true;
//accessor methods
boolean getCanSpawn()
{
return canSpawn;
}
int getSpawnTimer()
{
return spawnTimer;
}
int getKillTimer()
{
return killTimer;
}
int getKillFrequency()
{
return killFrequency;
}
//modifier methods
void switchCanSpawn()
{
if(canSpawn == true)
{
canSpawn = false;
}
else
{
canSpawn = true;
}
}
void setSpawnTimer(int spawnTimerIn)
{
spawnTimer = spawnTimerIn;
}
void setKillTimer(int killTimerIn)
{
killTimer = killTimerIn;
}
void setKillFrequency(int killFrequencyIn)
{
killFrequency = killFrequencyIn;
}
//constructor
public SpawnDirector()
{
}
//constructor with appropriate parameters
public SpawnDirector(int spawnTimerIn)
{
spawnTimer = spawnTimerIn;
}
void act()
{
if(canSpawn == true)
{
spawnTimer -= 1;
if(spawnTimer <= 0)
{
Alien alien = new Alien((int) (Math.random() * width), 0);
aliens.add(alien);
spawnTimer = alienSpawnRate;
}
}
}
}