// Declaring Variables. float zoogX; float zoogY; float zoogXX; float zoogYY; float eyeR; float eyeG; float eyeB; // Variables float r = 100; float g = 100; float b = 100; void setup() { size(720,600); // Set the size of the window // Feature #1. zoogX and zoogY are initialized based on the size of the window. // Note we cannot initialize these variables before the size() function is called // since we are using the built-in variables width and height. zoogX = width/2; // Zoog always starts in the middle zoogXX = width/2; // Zoog always starts in the middle smooth(); colorMode(RGB,100); } void draw() { background(r,g,b); // background // Line 1 middle strokeWeight(1); stroke(0); line(zoogX-19,zoogY-15,zoogX-19,height); line(zoogX+19,zoogY-15,zoogX+19,height); // lines strokeWeight(1); stroke(0); line(zoogX-119,zoogY-15,zoogX-119,height); line(zoogX+119,zoogY-15,zoogX+119,height); line(zoogX-109,zoogY-15,zoogX-109,height); line(zoogX+109,zoogY-15,zoogX+109,height); line(zoogX-99,zoogY-15,zoogX-99,height); line(zoogX+99,zoogY-15,zoogX+99,height); line(zoogX-89,zoogY-15,zoogX-89,height); line(zoogX+89,zoogY-15,zoogX+89,height); line(zoogX-79,zoogY-15,zoogX-79,height); line(zoogX+79,zoogY-15,zoogX+79,height); line(zoogX-69,zoogY-15,zoogX-69,height); line(zoogX+69,zoogY-15,zoogX+69,height); strokeWeight(2); stroke(0); line(zoogX-59,zoogY-15,zoogX-59,height); line(zoogX+59,zoogY-15,zoogX+59,height); line(zoogX-49,zoogY-15,zoogX-49,height); line(zoogX+49,zoogY-15,zoogX+49,height); line(zoogX-39,zoogY-15,zoogX-39,height); line(zoogX+39,zoogY-15,zoogX+39,height); line(zoogX-29,zoogY-15,zoogX-29,height); line(zoogX+29,zoogY-15,zoogX+29,height); // lines variables line(zoogXX-119,zoogYY-15,zoogXX-119,height); line(zoogXX+119,zoogYY-15,zoogXX+119,height); line(zoogXX-109,zoogYY-15,zoogXX-109,height); line(zoogXX+109,zoogYY-15,zoogXX+109,height); line(zoogXX-99,zoogYY-15,zoogXX-99,height); line(zoogXX+99,zoogYY-15,zoogXX+99,height); line(zoogX-89,zoogY-15,zoogX-89,height); line(zoogX+89,zoogY-15,zoogX+89,height); line(zoogX-79,zoogY-15,zoogX-79,height); line(zoogX+79,zoogY-15,zoogX+79,height); line(zoogX-69,zoogY-15,zoogX-69,height); line(zoogX+69,zoogY-15,zoogX+69,height); line(zoogX-59,zoogY-15,zoogX-59,height); line(zoogX+59,zoogY-15,zoogX+59,height); line(zoogX-49,zoogY-15,zoogX-49,height); line(zoogX+49,zoogY-15,zoogX+49,height); line(zoogX-39,zoogY-15,zoogX-39,height); line(zoogX+39,zoogY-15,zoogX+39,height); line(zoogX-29,zoogY-15,zoogX-29,height); line(zoogX+29,zoogY-15,zoogX+29,height); // Zoog moves up zoogY = zoogY - random(10,1); // EXERCISE SOLUTION zoogX = zoogX + random(-5,5) ; // Zoog moves up zoogYY = zoogYY - random(10,1); // EXERCISE SOLUTION zoogXX = zoogXX + random(-10,10) ; //mouse test // R // If the mouse is on the right side of the screen is equivalent to // "if mouseX is greater than width divided by 2." if(mouseX > width/2) { r = r + 0.5; } else { r = r - 0.5; } // If r is greater than 255, set it back to 255. // If r is less than 0, set it back to 0. if (r > 100) { r = 100; } else if (r < 0) { r = 0; } if(mouseY < height/2) { r = r + 0.5; } else { r = r - 0.5; } // If r is greater than 255, set it back to 255. // If r is less than 0, set it back to 0. if (r > 100) { r = 100; } else if (r < 0) { r = 0; } // G if(mouseX < width/2) { g = g + 0.05; } else { g = g - 0.05; } // If r is greater than 255, set it back to 255. // If r is less than 0, set it back to 0. if (g > 100) { g = 100; } else if (r < 0) { g = 0; } if(mouseX > width/2) { g = g - 0.05; } else { g = g + 0.05; } // If r is greater than 255, set it back to 255. // If r is less than 0, set it back to 0. if (g > 100) { g = 100; } else if (r < 0) { g = 0; } // B if(mouseY < height/2) { b = b + 0.5; } else { b = b - 0.5; } // If r is greater than 255, set it back to 255. // If r is less than 0, set it back to 0. if (b > 100) { b = 100; } else if (b < 0) { b = 0; } }