Skip to content

Commit

Permalink
Mover -> Boid
Browse files Browse the repository at this point in the history
  • Loading branch information
nbourre committed Sep 19, 2023
1 parent 2685508 commit 710a9ce
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
12 changes: 6 additions & 6 deletions s04_demo_boids/Mover.pde → s04_demo_boids/Boid.pde
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
class Mover extends GraphicObject {
class Boid extends GraphicObject {
float topSpeed = 2;
float topSteer = 0.03;

float theta = 0;
float r = 10; // Rayon du boid
float r = 10; // Rayon du Boid

float radiusSeparation = 10 * r;

float red, g, b;

boolean debugMode = false;

Mover () {
Boid () {
location = new PVector();
velocity = new PVector();
acceleration = new PVector();
}

Mover (PVector loc, PVector vel) {
Boid (PVector loc, PVector vel) {
this.location = loc.copy();
this.velocity = vel.copy();
this.acceleration = new PVector (0 , 0);
Expand Down Expand Up @@ -68,12 +68,12 @@ class Mover extends GraphicObject {
popMatrix();
}

PVector separate (ArrayList<Mover> boids) {
PVector separate (ArrayList<Boid> Boids) {
PVector steer = new PVector(0, 0, 0);

int count = 0;

for (Mover other : boids) {
for (Boid other : Boids) {
float d = PVector.dist(location, other.location);

if (d > 0 && d < radiusSeparation) {
Expand Down
12 changes: 6 additions & 6 deletions s04_demo_boids/s04_demo_boids.pde
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ int currentTime;
int previousTime;
int deltaTime;

ArrayList<Mover> flock;
ArrayList<Boid> flock;
int flockSize = 50;

boolean debugMode = false;
Expand All @@ -12,10 +12,10 @@ void setup () {
currentTime = millis();
previousTime = millis();

flock = new ArrayList<Mover>();
flock = new ArrayList<Boid>();

for (int i = 0; i < flockSize; i++) {
Mover m = new Mover(new PVector(random(0, width), random(0, height)), new PVector(random (-5, 5), random(-5, 5)));
Boid m = new Boid(new PVector(random(0, width), random(0, height)), new PVector(random (-5, 5), random(-5, 5)));
m.fillColor = color(random(255), random(255), random(255));
flock.add(m);
}
Expand All @@ -36,7 +36,7 @@ void draw () {
*/
void update(int delta) {

for (Mover m : flock) {
for (Boid m : flock) {

m.update(delta);
}
Expand All @@ -49,7 +49,7 @@ color saveColor = color(255);
void display () {
background(0);

for (Mover m : flock) {
for (Boid m : flock) {
m.display();
}
}
Expand All @@ -61,7 +61,7 @@ void keyPressed() {
debugMode = !debugMode;

// Mets en évidence le dernier boids
for (Mover m : flock) {
for (Boid m : flock) {

if (debugMode) {
if (m != flock.get(flock.size() - 1)) {
Expand Down

0 comments on commit 710a9ce

Please sign in to comment.