I want the eyes to appear in RED in one iteration of the Zoog object, and to appear GREEN in the second iteration of the Zoog object.
However the eyes are currently appearing BLACK in both iterations.
What have I done incorrectly in the code below:
Zoog zoog1;
Zoog zoog2;
void setup() {
size (200, 200);
zoog1 = new Zoog (color(255,0,0), 100, 125, 60, 60, 16);
zoog2 = new Zoog (color(0,255,0), 50, 60, 30, 30, 8);
}
void draw(){
background(255);
float factor = constrain (mouseX/10, 0, 5);
zoog1.jiggle(factor);
zoog1.display();
zoog2.jiggle(factor);
zoog2.display();
}
class Zoog {
float c, x, y, w, h, eyeSize;
Zoog (color tempC, float tempX, float tempY, float tempW, float tempH, float tempEyeSize) {
c = tempC;
x = tempX;
y = tempY;
w = tempW;
h = tempH;
eyeSize = tempEyeSize;
}
void jiggle (float speed) {
x = x + random(-1, 1)*speed;
y = y + random(-1, 1)*speed;
x = constrain(x, 0, width);
y = constrain(y, 0, height);
}
void display() {
rectMode(CENTER);
ellipseMode(CENTER);
//draw Zoog's arms with a for loop
for (float i = y - h/3; i < y + h/2; i += 10) {
stroke(0);
line(x - w/4, i, x + w/4, i);
}
//Zoog's body
stroke(0);
fill(175);
rect(x, y, w/6, h);
//Zoog's head
stroke(0);
fill(255);
ellipse(x, y-h, w, h);
//Zoog's eyes
noStroke();
fill(c);
ellipse(x-w/3, y-h, eyeSize, eyeSize*2);
ellipse(x+w/3, y-h, eyeSize, eyeSize*2);
//Zoog's legs
stroke(0);
line(x-w/12, y+h/2, x-w/4, y+h/2 +10);
line(x+w/12, y+h/2, x+w/4, y+h/2 +10);
}
}