Skip to content

Instantly share code, notes, and snippets.

@clavis-magna
Created May 12, 2015 00:32
Show Gist options
  • Save clavis-magna/a7f204fdf2aafe3feb9e to your computer and use it in GitHub Desktop.
Save clavis-magna/a7f204fdf2aafe3feb9e to your computer and use it in GitHub Desktop.
processing bouncing ball
int xPos = 0;
int speed = 4;
void setup(){
size(300,300);
}
void draw(){
background(150,150,150);
xPos = xPos + speed;
// || = OR && = AND
if(xPos > width || xPos < 0){
speed = speed * -1;
}
ellipse(xPos,150,20,20);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment