Pick one of the characters shown below, or create one of your own. Write a Proce
ID: 642268 • Letter: P
Question
Pick one of the characters shown below, or create one of your own. Write a Processing program, similar to example 3-6 in your Learning Processing textbook. Your character must move around the window in the same way. Draw a window that is 640 pixels wide by 480 pixels high.
// Learning Processing
// http://www.learningprocessing.com
// Example 3-6: Interactive Zoog?
void setup() {
// Set the size of the window
size(200,200);
smooth();
// The frame rate is set to 30 frames per second.
frameRate(30);
}
void draw() {
// Draw a white background
background(255);
// Set ellipses and rects to CENTER mode
ellipseMode(CENTER);
rectMode(CENTER);
// Draw Zoog's body
stroke(0);
fill(175);
rect(mouseX,mouseY,20,100);
// Draw Zoog's head
stroke(0);
fill(255);
ellipse(mouseX,mouseY-30,60,60);
// Draw Zoog's eyes
// The eye color is determined by the mouse location.
fill(mouseX,0,mouseY);
ellipse(mouseX-19,mouseY-30,16,32);
ellipse(mouseX+19,mouseY-30,16,32);
// Draw Zoog's legs
stroke(0);
// The legs are drawn according to the mouse location and the previous mouse location.
line(mouseX-10,mouseY+50,pmouseX-10,pmouseY+60);
line(mouseX+10,mouseY+50,pmouseX+10,pmouseY+60);
}
void mousePressed() {
println("Take me to your leader!");
}
Explanation / Answer
second