Skip to content

Instantly share code, notes, and snippets.

@slambert
Created February 11, 2020 23:27
Show Gist options
  • Save slambert/ff09153744db49c261fdcee2d4fbfb23 to your computer and use it in GitHub Desktop.
Save slambert/ff09153744db49c261fdcee2d4fbfb23 to your computer and use it in GitHub Desktop.
//Moving Ball
//Steve Lambert February 11, 2020
//v0.1
//variables
color darkBlue = color(34,83,120);
color medBlue = color(22,149,163);
color lightBlue = color(172,240,242);
color offWhite = color(243,255,226);
color orange = color(235,127,0);
float circleWidth = 75.5; // <-- width of my circles!
int circleX = 76;
int rate = 1;
void setup() {
size(1000, 500);
background(offWhite);
noStroke();
println("setup done");
} // end setup
void draw(){
background(offWhite);
fill(lightBlue);
ellipse(circleX,height/2,circleWidth,circleWidth);
if(circleX >= width - (circleWidth/2) || circleX <= 0 + (circleWidth/2)){
rate = rate * -1;
}
circleX = circleX + rate;
println("circleX = " + circleX);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment