Created
May 12, 2015 00:32
-
-
Save clavis-magna/a7f204fdf2aafe3feb9e to your computer and use it in GitHub Desktop.
processing bouncing ball
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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