diff options
Diffstat (limited to 'resources/js/scene.js')
-rw-r--r-- | resources/js/scene.js | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/resources/js/scene.js b/resources/js/scene.js index d035827..645bb9e 100644 --- a/resources/js/scene.js +++ b/resources/js/scene.js @@ -9,35 +9,27 @@ class Scene { this.no_of_components = no_of_components; this.components = []; this.gameArea = {}; + this.started = false; + this.width = 600; + this.height = 600; + this.initGameArea(); this.initComponents(); - this.started = false; } initComponents() { let components = []; for (let i = 0; i < this.no_of_components; i++) { - // let x, y, z; - // if (i == 0) { - // x = 100; - // y = 100; - // z = 0; - // } else { - // x = 105; - // y = 100; - // z = 180; - // } - components.push(new Boid( - this.gameArea.context, this.component_size, "black", 300, 300, Math.random() * 360, - // x, y, z, // Math.random() * (this.gameArea.canvas.width - 100) + 50, // Math.random() * (this.gameArea.canvas.height - 100) + 50, // Math.random() * 360, - i + i, + this.width, + this.height )); } @@ -45,7 +37,7 @@ class Scene { } initGameArea() { - this.gameArea = new GameArea(600, 600); + this.gameArea = new GameArea(this.width, this.height); this.gameArea.init() } @@ -65,7 +57,8 @@ class Scene { update() { this.gameArea.clear(); for (let i = 0; i < this.no_of_components; i++) { - this.components[i].move(this.gameArea.context, this.components); + this.components[i].move(this.components); + this.components[i].draw(this.gameArea.context); } } |