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.js33
1 files changed, 24 insertions, 9 deletions
diff --git a/resources/js/scene.js b/resources/js/scene.js
index 684cd11..7e7e895 100644
--- a/resources/js/scene.js
+++ b/resources/js/scene.js
@@ -3,7 +3,7 @@ class Scene {
constructor(component_size, no_of_components) {
this.component_size = component_size;
this.no_of_components = no_of_components;
- this.components = new Array;
+ this.components = [];
this.gameArea = {};
this.initGameArea();
this.initComponents();
@@ -11,17 +11,32 @@ class Scene {
}
initComponents() {
+ let components = [];
for (let i = 0; i < this.no_of_components; i++) {
- let new_component = new Component(
+ let x, y, z;
+ if (i == 0) {
+ x = 100;
+ y = 100;
+ z = 0;
+ } else {
+ x = 105;
+ y = 100;
+ z = 180;
+ }
+
+ components.push(new Component(
+ this.gameArea.context,
this.component_size,
"black",
- Math.random() * this.gameArea.canvas.width,
- Math.random() * this.gameArea.canvas.height,
- Math.random() * 360
- // 18, 100, 180
- );
- this.components.push(new_component);
+ // x, y, z,
+ Math.random() * (this.gameArea.canvas.width - 100) + 50,
+ Math.random() * (this.gameArea.canvas.height - 100) + 50,
+ Math.random() * 360,
+ i
+ ));
}
+
+ this.components = components;
}
initGameArea() {
@@ -45,7 +60,7 @@ 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[i].move(this.gameArea.context, this.components);
}
}