-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPathfinder.pde
More file actions
34 lines (32 loc) · 903 Bytes
/
Pathfinder.pde
File metadata and controls
34 lines (32 loc) · 903 Bytes
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
class pathfinder {
PVector location;
PVector velocity;
float diameter;
float incr = 0.001;
float angle = 0.0;
pathfinder(float xroot, float yroot) {
location = new PVector(xroot, yroot);
velocity = PVector.fromAngle(random(1)*2*PI);
diameter = 5;
}
pathfinder(pathfinder parent) {
location = parent.location.get();
velocity = parent.velocity.get();//.add(PVector.fromAngle(random(-0.001, 0.001)*2*PI));
float area = PI*sq(parent.diameter*0.75);
float newDiam = sqrt(area/2/PI)*2;
diameter = newDiam;
parent.diameter = newDiam;
}
void update() {
if (diameter>0.5) {
location.add(velocity);
PVector bump = new PVector(random(-1, 1), random(-1, 1));
if (diameter>25) {
bump = new PVector(random(-0.5, 0.5), random(-1, 0));
}
bump.mult(0.2);
velocity.add(bump);
velocity.normalize();
}
}
}