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.js32
1 files changed, 16 insertions, 16 deletions
diff --git a/resources/js/scene.js b/resources/js/scene.js
index 645bb9e..df456d3 100644
--- a/resources/js/scene.js
+++ b/resources/js/scene.js
@@ -4,24 +4,24 @@ class Scene {
// no of boids
// scene width
// scene height
- constructor(component_size, no_of_components) {
- this.component_size = component_size;
- this.no_of_components = no_of_components;
- this.components = [];
+ constructor(boid_radius, no_of_boids) {
+ this.boid_radius = boid_radius;
+ this.no_of_boids = no_of_boids;
+ this.boids = [];
this.gameArea = {};
this.started = false;
this.width = 600;
this.height = 600;
this.initGameArea();
- this.initComponents();
+ this.initBoids();
}
- initComponents() {
- let components = [];
- for (let i = 0; i < this.no_of_components; i++) {
- components.push(new Boid(
- this.component_size,
+ 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,
@@ -33,7 +33,7 @@ class Scene {
));
}
- this.components = components;
+ this.boids = boids;
}
initGameArea() {
@@ -56,9 +56,9 @@ class Scene {
update() {
this.gameArea.clear();
- for (let i = 0; i < this.no_of_components; i++) {
- this.components[i].move(this.components);
- this.components[i].draw(this.gameArea.context);
+ for (let i = 0; i < this.no_of_boids; i++) {
+ this.boids[i].move(this.boids);
+ this.boids[i].draw(this.gameArea.context);
}
}
@@ -76,8 +76,8 @@ class Scene {
if (this.started) {
this.stop();
}
- this.components = new Array;
- this.initComponents();
+ this.boids = new Array;
+ this.initBoids();
this.gameArea.clear();
this.started = false;
}