summaryrefslogtreecommitdiff
path: root/resources/js/scene.js
diff options
context:
space:
mode:
Diffstat (limited to 'resources/js/scene.js')
-rw-r--r--resources/js/scene.js21
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() {