Last active
December 24, 2015 07:59
-
-
Save ohmygodwin/6767115 to your computer and use it in GitHub Desktop.
i created a pattern animation with a simple bouncing ball algorithm!
This file contains 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
float bbycircle; | |
float bbycircle2; | |
float speed = 6; | |
float speed2 = 12; | |
void setup() { | |
size(662, 304); | |
background(255); | |
} | |
void draw() { | |
bbycircle = bbycircle + speed; | |
bbycircle2 = bbycircle2 + speed2; | |
if ((bbycircle > width) || (bbycircle < 0)) { | |
speed = -speed; | |
} | |
if ((bbycircle2 > height) || (bbycircle2 < 0)) { | |
speed2 = -speed2; | |
} | |
stroke(255,0,0); | |
fill(255); | |
ellipse(bbycircle,bbycircle2,5,5); | |
} | |
void mouseClicked(){ | |
setup(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment