Skip to content

Instantly share code, notes, and snippets.

@ohmygodwin
Last active December 24, 2015 07:59
Show Gist options
  • Save ohmygodwin/6767115 to your computer and use it in GitHub Desktop.
Save ohmygodwin/6767115 to your computer and use it in GitHub Desktop.
i created a pattern animation with a simple bouncing ball algorithm!
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