var boids = [];

/**
 * P5js initialization
 */
function setup() {

  createCanvas(640, 480);

  for (var i = 0; i < 10; i++) {
    boids.push(new Boid(10*i, 10*i, 10));
  }

}

/**
 * P5js render loop
 */
function draw() {

  // Paint the background white
  background(255);

  boids.forEach(function(boid) {
    var gravity = createVector(0, 0.1);
    boid.applyForce(gravity);
  });

  boids.forEach(
    Boid.prototype.update
  );

  boids.forEach(
    Boid.prototype.display
  );

}

/**
 * Boid class
 */
function Boid(x_pos, y_pos, mass) {
  this.position= createVector(x_pos, y_pos);
  this.velocity = createVector(0, 0);
  this.acceleration = createVector(0, 0);
  this.mass = mass;
}

Boid.prototype = {
  constructor: Boid,
  update:function (self) {
    self.velocity.add(self.acceleration);
    self.position.add(self.velocity);
    self.acceleration.mult(0);
  },
  display:function (self) { 
    ellipse(self.position.x, self.position.y, 80, 80);
  },
  checkEdges:function () { 
    // TODO
  },
  applyForce:function (force) {
    this.acceleration.add(force.copy().div(this.mass));
  }
}

@@ -274,43 +274,8 @@
 );%0A%0A
-  boids.forEach(function(boid) %7B%0A  
   va
@@ -307,16 +307,50 @@
 0, 0.1);
+%0A%0A  boids.forEach(function(boid) %7B
 %0A    boi
@@ -378,105 +378,41 @@
 ;%0A  
-%7D);%0A%0A
   boid
-s.forEach(%0A    Boid.prototype
 .update
-%0A  
+(
 );%0A
-%0A
   
+  
 boid
-s.forEach(%0A    Boid.prototype
 .display
 %0A  )
@@ -407,19 +407,23 @@
 .display
+();
 %0A  
+%7D
 );%0A%0A%7D%0A%0A/
@@ -690,20 +690,16 @@
 on (
-self
 ) %7B%0A    
 self
@@ -694,20 +694,20 @@
 ) %7B%0A    
-self
+this
 .velocit
@@ -712,20 +712,20 @@
 ity.add(
-self
+this
 .acceler
@@ -736,20 +736,20 @@
 n);%0A    
-self
+this
 .positio
@@ -754,20 +754,20 @@
 ion.add(
-self
+this
 .velocit
@@ -774,20 +774,20 @@
 y);%0A    
-self
+this
 .acceler
@@ -826,20 +826,16 @@
 nction (
-self
 ) %7B %0A   
@@ -843,20 +843,20 @@
 ellipse(
-self
+this
 .positio
@@ -864,12 +864,12 @@
 .x, 
-self
+this
 .pos
@@ -964,24 +964,94 @@
 n (force) %7B%0A
+    // Force = mass * acceleration%0A    // acceleration = Force / mass%0A
     this.acc

Fix silly performance issue :sweat_smile: