Skip to content

Instantly share code, notes, and snippets.

@claytical
Created October 6, 2015 15:36
Show Gist options
  • Save claytical/91191330591030ecfce5 to your computer and use it in GitHub Desktop.
Save claytical/91191330591030ecfce5 to your computer and use it in GitHub Desktop.
Array of Object Changes
var Ball = function() {
this.x = random(width);
this.y = random(height);
this.speedX = random(-1,1);
this.diameter = random(20,50);
}
var balls = [];
function setup() {
createCanvas(windowWidth, windowHeight);
}
function draw() {
background(0);
for (var i = 0; i < balls.length; i++) {
ellipse(balls[i].x, balls[i].y, balls[i].diameter, balls[i].diameter);
balls[i].x = balls[i].x + balls[i].speedX;
}
if (frameCount%15 == 0 && balls.length < 10000) {
// balls.push(new Ball());
}
}
function mousePressed() {
balls.push( new Ball() );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment