Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
Updated background colours & default variables
Browse files Browse the repository at this point in the history
  • Loading branch information
WhenLifeHandsYouLemons committed Aug 14, 2024
1 parent 5396abc commit 09005ba
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 28 deletions.
4 changes: 2 additions & 2 deletions EnemyBoid.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ class EnemyBoid {
}

if (direction) {
stroke(0, 0, 255);
strokeWeight(2);
stroke(255);
strokeWeight(3);
line(this.position.x, this.position.y, this.position.x + (this.velocity.x * 5), this.position.y + (this.velocity.y * 5));
}

Expand Down
4 changes: 2 additions & 2 deletions EnemyBoidOptimised.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ class EnemyBoidOptimised {
}

if (direction) {
stroke(0, 0, 255);
strokeWeight(2);
stroke(255);
strokeWeight(3);
line(this.position.x, this.position.y, this.position.x + (this.velocity.x * 5), this.position.y + (this.velocity.y * 5));
}

Expand Down
4 changes: 2 additions & 2 deletions FriendlyBoid.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ class FriendlyBoid {
}

if (direction) {
stroke(0, 0, 255);
strokeWeight(2);
stroke(255);
strokeWeight(3);
line(this.position.x, this.position.y, this.position.x + (this.velocity.x * 5), this.position.y + (this.velocity.y * 5));
}

Expand Down
4 changes: 2 additions & 2 deletions FriendlyBoidOptimised.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ class FriendlyBoidOptimised {
}

if (direction) {
stroke(0, 0, 255);
strokeWeight(2);
stroke(255);
strokeWeight(3);
line(this.position.x, this.position.y, this.position.x + (this.velocity.x * 5), this.position.y + (this.velocity.y * 5));
}

Expand Down
44 changes: 24 additions & 20 deletions sketch.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,21 @@ if (settings_dock == 'left') {
canvas_position = 0;
}

let friendly_boid_count = 75;
let enemy_boid_count = 10;
// Boid variables
let friendly_boid_count = 200;
let enemy_boid_count = 3;
let enemy_boid_attack_constant = 0.5;
let enemy_avoidance_constant = 0.5;
let enemy_avoidance_range = 100;
let avoidance_constant = 0.05;
let alignment_constant = 0.05;
let cohesion_constant = 0.005;
let enemy_avoidance_constant = 0.75;
let enemy_avoidance_range = 150;
let avoidance_constant = 0.15;
let alignment_constant = 0.3;
let cohesion_constant = 0.04;
let interest_constant = 0.1;
let poi_avoidance_constant = 0.5;
let turn_constant = 0.3;
let margin = 100;
let avoidance_range = 15;
let visible_range = 40;
let avoidance_range = 25;
let visible_range = 65;
let poi_attraction_range = 500;
let poi_protection_range = 50;
let max_speed = 5;
Expand Down Expand Up @@ -155,26 +156,29 @@ function draw() {
enemy_boids.pop();
}

background(150);
background(0);

// Draw the margins
if (options[15].checked()) {
drawMargins();
}

// Draw points of interest
for (let poi of pointsOfInterest) {
poi.draw(protect_range = options[19].checked(), attract_range = options[17].checked());
}

// Draw friendly boids
for (let boid of friendly_boids) {
boid.update(trail = options[20].checked(), update = is_updating);
boid.draw(trail = options[20].checked(), shape = options[22].value(), direction = options[21].checked(), range = options[11].checked(), avoid = options[7].checked());
}

// Draw enemy boids
for (let boid of enemy_boids) {
boid.update(trail = options[20].checked(), update = is_updating);
boid.draw(trail = options[20].checked(), shape = options[22].value(), direction = options[21].checked(), range = options[11].checked(), avoid = options[7].checked());
}

for (let poi of pointsOfInterest) {
poi.draw(protect_range = options[19].checked(), attract_range = options[17].checked());
}

// Draw the margins
if (options[15].checked()) {
drawMargins();
}
}

function keyPressed() {
Expand All @@ -199,7 +203,7 @@ function keyPressed() {
function drawMargins() {
margin = options[14].value();

stroke(150, 0, 0, 50);
stroke(150, 0, 0, 200);
strokeWeight(2);
noFill();
rect(margin, margin, width - 2 * margin, height - 2 * margin);
Expand Down

0 comments on commit 09005ba

Please sign in to comment.