Skip to content

Instantly share code, notes, and snippets.

@lmccart
Created October 5, 2015 22:54
Show Gist options
  • Save lmccart/e21eb50c0a4a2a22dc09 to your computer and use it in GitHub Desktop.
Save lmccart/e21eb50c0a4a2a22dc09 to your computer and use it in GitHub Desktop.
var y = 0;
var isEllipse = true;
function setup() {
createCanvas(600, 400);
rectMode(CENTER);
}
function draw() {
background(0);
if (isEllipse == true) {
ellipse(width / 2, y, 50, 50);
} else {
rect(width / 2, y, 50, 50);
}
if (y > height) {
isEllipse = false;
}
if (y < 0) {
isEllipse = true;
}
}
function keyPressed() {
if (keyCode == DOWN_ARROW) {
y += 10;
} else if (keyCode == UP_ARROW) {
y -= 10;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment