๐Ÿ“ฆ sbuggay / boids

๐Ÿ“„ script.js ยท 30 lines
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
30const flock = [];
let qt;

function setup() {  
    createCanvas(800, 800);


    for (let i = 0; i < 200; i++) {
        const boid = new Boid()
        flock.push(boid);

    }

    
}

function draw() {
    background(51);

    qt = new QuadTree(new Rect(width / 2, height / 2, width / 2, height / 2), 2);


    for (let boid of flock) {
        boid.update(flock);
        qt.insert(boid.position);
        boid.render();
    }

    qt.render();
}