Created
October 6, 2015 15:36
-
-
Save claytical/91191330591030ecfce5 to your computer and use it in GitHub Desktop.
Array of Object Changes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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