Created
October 3, 2015 16:50
-
-
Save claytical/1bde490f08b2aba5ec36 to your computer and use it in GitHub Desktop.
Simple Object with Array Example
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 = mouseX; | |
| this.y = mouseY; | |
| this.diameter = 10; | |
| } | |
| 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); | |
| } | |
| } | |
| function mousePressed() { | |
| balls.push( new Ball() ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment