Created
September 24, 2014 12:21
-
-
Save rlieberman/e4707e5dad53317c7276 to your computer and use it in GitHub Desktop.
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
//x position of circle | |
float circleX = 0; | |
//y position of circle | |
float circleY = 180; | |
//x-speed of circle | |
float xspeed = 5; | |
//y-speed of circle | |
float yspeed = random (10); | |
//boolean variable for the movement of the circle | |
boolean moving = false; | |
void setup () { | |
size (640,400); | |
background (50); | |
} | |
void draw () { | |
//distance from center of screen | |
float d = dist(width/2, height/2, mouseX, mouseY); | |
//maximum distance | |
float maxDist = dist(0, 0, width/2, height/2); | |
fill (random(200, 250), random (200, 250), random(200, 250)); | |
ellipse (circleX, circleY, d, d); | |
//bouncing horizontally | |
circleX=circleX + xspeed; | |
if ((circleX > width) || (circleX <=0)) { | |
xspeed = -xspeed; | |
} | |
//bouncing vertically | |
circleY = circleY + yspeed; | |
if ((circleY > height) || (circleY<0)) { | |
yspeed = -yspeed; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment