-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparticle_flow.pde
45 lines (34 loc) · 899 Bytes
/
particle_flow.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
Particle[] p = new Particle[50];
FlowField ff;
int rows, cols;
int resolution = 20;
float offset = 0.1;
float zoff = 0;
PVector[] flowfieldArr;
void setup(){
size(400,400);
//resolution = 20;
rows = floor(height/resolution);
cols = floor(width/resolution);
flowfieldArr = new PVector[rows*cols];
//create a flow field
ff = new FlowField(offset,resolution,rows,cols,flowfieldArr);
//spawn some particles in the field
for (int i=0;i < p.length;i++){
p[i] = new Particle(rows,cols,resolution,flowfieldArr);
}
}
void draw(){
background(255);
//draw the flow field
ff.init(offset,resolution,flowfieldArr);
//give the required properties to each particle
for (Particle par : p){
par.follow(flowfieldArr);
par.update();
par.display();
par.checkEdges();
}
//check the frame rate
println("Frame rate = "+floor(frameRate));
}