prototype -- move
Boid.prototype.move = function() {
// RaphaĞl JS doesn't provide any way to GET the position once
// we've moved it so we'll need to manually track the position
this.x += this.xVelocity;
this.y += this.yVelocity;
var border = 5;
if(this.x <= border || this.x >= width - border) {
this.x -= this.xVelocity;
this.x = Math.max(this.x, border);
this.x = Math.min(this.x, width - border);
this.xVelocity = -this.xVelocity;
this.x += this.xVelocity;
}
if(this.y <= border || this.y >= height - border) {
this.y -= this.yVelocity;
this.y = Math.max(this.y, border);
this.y = Math.min(this.y, height - border);
this.yVelocity = -this.yVelocity;
this.y += this.yVelocity;
}
this.circle.translate(this.xVelocity, this.yVelocity);
}