Skip to content

Instantly share code, notes, and snippets.

@kmancher
Created February 13, 2019 19:07
Show Gist options
  • Select an option

  • Save kmancher/e0cd5457ff562f1ec38c352c88106c17 to your computer and use it in GitHub Desktop.

Select an option

Save kmancher/e0cd5457ff562f1ec38c352c88106c17 to your computer and use it in GitHub Desktop.
Bobbing object
float yPos = 200;
void setup() {
size(640, 360);
noStroke();
}
void draw() {
background(0, 255, 255);
fill(0, 0, 255);
rect(0, height/2, width, height);
fill(255);
ellipse(width/2, yPos, 50, 50);
yPos = yPos + 10;
if(yPos < 200) {
yPos +=10;
} else if (yPos > 160) {
yPos -= 10;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment