-
Notifications
You must be signed in to change notification settings - Fork 0
/
Node.pde
64 lines (55 loc) · 1.29 KB
/
Node.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
class Node {
float x;
float y;
float radius;
float maxRadius;
float volatileRadius;
float growthRate;
boolean isFlagged = false;
Node(float x, float y, float maxRadius) {
this.x = x;
this.y = y;
radius = 10;
this.maxRadius = maxRadius;
growthRate = 20;
volatileRadius = maxRadius + 2;
}
void update() {
if(isFlagged) {
return;
}
fill(0, 200, 0);
if (radius < maxRadius) {
radius += (1 / (radius * 10)) * growthRate;
}
ellipse(x, y, radius * 2, radius * 2);
if (isCollidingWithPlayer()) {
for (int i = 0; i < radius / 5; i++) {
PVector v = player.getVelocity();
v.rotate(radians(random(-20, 20)));
projectiles.add(new Projectile(x, y, v));
}
isFlagged = true;
}
textSize(15);
fill(255, 255, 255);
textAlign(CENTER, CENTER);
}
void absorbProjectile() {
if(isFlagged) {
return;
}
radius++;
if (radius > volatileRadius) {
for (int i = 0; i < radius / 5; i++) {
PVector v = player.getVelocity();
v.rotate(radians(random(0, 360)));
projectilesToBeAdded.add(new Projectile(x, y, v));
}
isFlagged = true;
}
}
boolean isCollidingWithPlayer() {
return dist(x, y, player.x, player.y) < radius;
}
}