-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsketch.js
More file actions
38 lines (28 loc) · 717 Bytes
/
Copy pathsketch.js
File metadata and controls
38 lines (28 loc) · 717 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
35
36
37
38
// Shivank Sharma
// Based on Boids Algorithm by Craig Reynolds.
// Implemented in p5.js
const flock = [];
let canvas, alignSlider, cohesionSlider, separationSlider;
function setup(){
canvas = createCanvas(windowWidth * 0.8, 700);
canvas.parent('#canvas');
alignSlider = createSlider(0, 3, 1, 0.1);
alignSlider.parent("#slider1");
cohesionSlider = createSlider(0, 3, 1, 0.1);
cohesionSlider.parent("#slider2");
separationSlider = createSlider(0, 4, 1, 0.1);
separationSlider.parent("#slider3");
for(let i=0; i<100; i++){
flock.push(new Boid());
}
}
function draw(){
background(130);
for(let boid of flock){
boid.flock(flock);
boid.show();
}
for(let boid of flock){
boid.update();
}
}