Created
September 19, 2018 01:07
-
-
Save esthernam1/f22a721083f3fabcbaf84242b428473c 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
int circle; | |
int circleSize; | |
int circleX, circleY; | |
int distance; | |
float x; | |
float y; | |
int xspeed; | |
int yspeed; | |
color circleColor, bgColor; | |
boolean circlePressed; | |
//boolean circlePressed2; | |
float xPos, yPos; | |
float dist; | |
//float r, g, b; | |
//float speedX, speedY; | |
//float ballX, ballY; | |
//float ballSize; | |
void setup() { | |
size(500, 500); | |
bgColor = color(30, 200, 200); | |
background(bgColor); | |
x = -width/2; | |
y = -height/2; | |
xPos = width*.75; | |
yPos = height*.25; | |
circleSize = 100; | |
xspeed =10; | |
yspeed =20; | |
} | |
void draw() { | |
distance = int(dist(xPos, yPos, mouseX, mouseY)); | |
background(bgColor); | |
if (distance<circleSize/2) { | |
circleColor = color(0, 230, 172); | |
} else { | |
circleColor = color(255, 163, 102); | |
} | |
if (circlePressed == true) { | |
bgColor = color(179, 203, 255); | |
} else { | |
bgColor = color(255, 255, 204); | |
} | |
println(circlePressed); | |
fill(circleColor); | |
ellipse(xPos, yPos, circleSize, circleSize); | |
noStroke(); | |
//center GREEN circle | |
fill(0, 130, 170); | |
ellipse(x, y, circleSize, circleSize); | |
fill(127); | |
ellipse(mouseX, mouseY, 50, 50); | |
x= x+xspeed; | |
y= y+yspeed; | |
int distance2 = int (dist(xPos, yPos, mouseX, mouseY)); | |
println(distance2); | |
if (x>=width-circleSize/2) { | |
xspeed = xspeed * -1; | |
} else if (y>= height- circleSize/2) { | |
yspeed = yspeed * -1; | |
} else if (x<= 0+circleSize/2) { | |
xspeed = xspeed * -1; | |
} else if (y<= 0+circleSize/2) { | |
yspeed = yspeed * -1; | |
} | |
} | |
void mousePressed() { | |
if (distance<circleSize/2) { | |
circlePressed = !circlePressed; | |
println(circlePressed); | |
} | |
x= random(circleSize/2, width-circleSize/2); | |
y= random (circleSize/2, height-circleSize/2); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment