Skip to content
This repository was archived by the owner on Sep 22, 2024. It is now read-only.

Commit 2895cfb

Browse files
authored
Update bloop.js
Corrected borders behaviors.
1 parent 7d2a4dc commit 2895cfb

File tree

1 file changed

+5
-5
lines changed
  • chp09_ga/NOC_9_05_EvolutionEcosystem

1 file changed

+5
-5
lines changed

chp09_ga/NOC_9_05_EvolutionEcosystem/bloop.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,10 @@ class Bloop {
7171

7272
// Wraparound
7373
borders() {
74-
if (this.position.x < -this.r) this.position.x = width + this.r;
75-
if (this.position.y < -this.r) this.position.y = height + this.r;
76-
if (this.position.x > this.width + this.r) this.position.x = -r;
77-
if (this.position.y > this.height + this.r) this.position.y = -r;
74+
if (this.position.x < 0) this.position.x = width-this.r/2;
75+
if (this.position.y < 0) this.position.y = height-this.r/2;
76+
if (this.position.x > width) this.position.x = this.r/2;
77+
if (this.position.y > height) this.position.y = this.r/2;
7878
}
7979

8080
// Method to display
@@ -93,4 +93,4 @@ class Bloop {
9393
return false;
9494
}
9595
}
96-
}
96+
}

0 commit comments

Comments
 (0)