-
Notifications
You must be signed in to change notification settings - Fork 0
/
Enemy.pde
57 lines (49 loc) · 1.16 KB
/
Enemy.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
class Enemy extends Actor
{
// BOID
float detectDist, swarmDist;
PVector sep, align, coh;
float sepStrength, alignStrength, cohStrength;
Enemy(float x, float y, float z, float w, float h, float d)
{
super(x, y, z, w, h, d);
body.setFill(color(255, 0, 0));
// Movement
hVel.set(world.player.pos.x - x, world.player.pos.z - z);
hVel.normalize();
// BOID
swarmDist = 128;
detectDist = 16;
sep = new PVector(0, 0);
align = new PVector(0, 0);
coh = new PVector(0, 0);
sepStrength = 0.02;
alignStrength = 3;
cohStrength = 0.2;
}
void draw()
{
super.draw();
if (debugMode)
{
// Debug BEGIN
pushMatrix();
// Detection sphere (BOIDS)
translate(pos.x, pos.y - h * 0.5, pos.z);
noFill();
stroke(255);
//sphere(detectDist);
// BOID Vectors
stroke(255, 255, 0);
line(0, 0, 0, sep.x, 0, sep.y);
stroke(0, 255, 255);
line(0, 0, 0, align.x, 0, align.y);
stroke(255, 0, 255);
line(0, 0, 0, coh.x, 0, coh.y);
// Debug END
stroke(0);
fill(255);
popMatrix();
}
}
}