Skip to content

Instantly share code, notes, and snippets.

@claytical
Created September 22, 2015 02:27
Show Gist options
  • Save claytical/42d321e8d781182bd1a6 to your computer and use it in GitHub Desktop.
Save claytical/42d321e8d781182bd1a6 to your computer and use it in GitHub Desktop.
Simple Array with Text
var selectedBall;
var ballSizes;
function setup() {
createCanvas(windowWidth, windowHeight);
selectedBall = 0;
ballSizes = [40,50,30,20];
}
function draw() {
background(0);
textSize(30);
textAlign(CENTER);
fill(255);
stroke(127,0,127);
strokeWeight(3);
text("CURRENT BALL SELECTED: " + selectedBall, width/2, height/2);
fill(127,127,0);
noStroke();
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