diff options
author | Fbenas <philbeansburton@gmail.com> | 2020-10-14 00:48:34 +0100 |
---|---|---|
committer | Fbenas <philbeansburton@gmail.com> | 2020-10-14 00:48:34 +0100 |
commit | 81caa72aed6ad8f653aabb191b099ec3d544bf2b (patch) | |
tree | 8f69d5d6c55d5d3d3e94df3a66b865473ac3b345 /resources/js/scene.js | |
parent | 2df948ca0509b8bf58d1b7bc3a5ce0840132edd1 (diff) |
Diffstat (limited to 'resources/js/scene.js')
-rw-r--r-- | resources/js/scene.js | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/resources/js/scene.js b/resources/js/scene.js index 770eb92..f8858b6 100644 --- a/resources/js/scene.js +++ b/resources/js/scene.js @@ -19,14 +19,15 @@ class Scene { initBoids() { let boids = []; + for (let i = 0; i < this.no_of_boids; i++) { boids.push(new Boid( this.boid_radius, "black", - // 300, 300, Math.random() * 360, - Math.random() * (this.gameArea.canvas.width - 100) + 50, - Math.random() * (this.gameArea.canvas.height - 100) + 50, - Math.random() * 360, + // 300, 300, 90, + parseFloat(Number(Math.random() * (this.gameArea.canvas.width - 100) + 50).toFixed(1)), + parseFloat(Number(Math.random() * (this.gameArea.canvas.height - 100) + 50).toFixed(1)), + parseFloat(Number(Math.random() * 360).toFixed(2)), i, this.width, this.height @@ -55,11 +56,19 @@ class Scene { } update() { + if (!this.started) { + return; + } this.gameArea.clear(); - for (let i = 0; i < this.no_of_boids; i++) { - this.boids[i].move(this.boids); + for (let i = 0; i < this.boids.length; i++) { + let result = this.boids[i].move(this.boids); this.boids[i].draw(this.gameArea.context); + if (!result) { + continue; + } + } + return true; } stop() { |