-
Notifications
You must be signed in to change notification settings - Fork 0
/
ZombiesOMG.pde
61 lines (55 loc) · 1.15 KB
/
ZombiesOMG.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
SimpleFigure Tom;
SimpleFigure Dick;
SimpleFigure Harry;
int population = 500;
SimpleFigure[] zombie = new SimpleFigure[population];
int index = 0;
void setup()
{
size(1000, 700);
Tom = new SimpleFigure(width/2-50,height/2);
Dick = new SimpleFigure(width/2,height/2);
Harry = new SimpleFigure(width/2+50,height/2);
for (int i = 0; i < population; i++)
{
zombie[i] = new SimpleFigure();
}
}
void draw()
{
background(40);
Tom.drawMe();
Dick.drawMe();
Harry.drawMe();
Tom.moveMe();
Dick.moveMe();
Harry.moveMe();
for (int i = 0; i < population; i++)
{
zombie[i].drawMe();
zombie[i].moveMe();
if (Tom.intersect(zombie[i])
|| Dick.intersect(zombie[i])
|| Harry.intersect(zombie[i]))
{
zombie[i].setVX(0);
zombie[i].setVY(0);
}
}
}
// the following changes the X,Y of the index zombie to current mouse position with no effect on velocity
void mouseClicked()
{
println("index is: " + index);
if (index < population )
{
// zombie[index] = new SimpleFigure(mouseX,mouseY);
zombie[index].setX(mouseX) ;
zombie[index].setY(mouseY) ;
index ++;
}
else
{
index = 0;
}
}