Skip to content

Instantly share code, notes, and snippets.

@claytical
Created September 22, 2015 02:21
Show Gist options
  • Save claytical/ab534b5f83a8c2e6bf22 to your computer and use it in GitHub Desktop.
Save claytical/ab534b5f83a8c2e6bf22 to your computer and use it in GitHub Desktop.
Simple Array Example
var selectedBall;
var ballSizes;
function setup() {
createCanvas(windowWidth, windowHeight);
selectedBall = 0;
ballSizes = [40,50,30,20];
}
function draw() {
background(0);
ellipse(mouseX, mouseY, ballSizes[selectedBall], ballSizes[selectedBall]);
}
function mousePressed() {
selectedBall++;
if (selectedBall >= ballSizes.length) {
selectedBall = 0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment