summaryrefslogtreecommitdiff
path: root/public/js/app.js
diff options
context:
space:
mode:
Diffstat (limited to 'public/js/app.js')
-rw-r--r--public/js/app.js32
1 files changed, 16 insertions, 16 deletions
diff --git a/public/js/app.js b/public/js/app.js
index 53581b3..093d6df 100644
--- a/public/js/app.js
+++ b/public/js/app.js
@@ -230,24 +230,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,
@@ -259,7 +259,7 @@ class Scene {
));
}
- this.components = components;
+ this.boids = boids;
}
initGameArea() {
@@ -282,9 +282,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);
}
}
@@ -302,8 +302,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;
}