I'm playing around with some code and I'm trying to get the orbiting circle to change colour when hovered over. I'm not really sure what I'm doing wrong here.
// Angle of rotation around sun and planets
float theta = 0;
float x,y,w;
boolean mouse;
void setup() {
size(200,200);
smooth();
x = 0;
y = 0;
w = 10;
mouse = false;
}
void draw() {
background(255);
stroke(0);
// Translate to center of window to draw the sun.
//position of rotate origin
translate(width/2,height/2);
fill(255,200,50);
ellipse(0,0,20,20);
// The earth rotates around the sun
pushMatrix();
rotate(theta);
//position relative to sun
translate(50,0);
fill(50,200,255);
ellipse(x,y,w,w);
if (mouse) {
fill(0);
} else {
fill(50,200,255);
}
popMatrix();
theta += 0.001;
}
void rollover(int mx, int my) {
if (mx > x && mx < x + w && my > y && my < y + w) {
mouse = true;
} else {
mouse = false;
}
}