// Dartmouth CS 2, Winter 2009, Chris Bailey-Kellogg // Notes 6 | Sketch 6 void setup() { size(300,200); smooth(); // Note that we only need to load the font once, so we do it in the setup() textFont(loadFont("TrebuchetMS-24.vlw")); frameRate(8); } void draw() { background(128); // Invariant stuff ellipse(130,40,40,40); // head ellipse(130,90,70,70); // torso ellipse(130,160,90,90); // legs? strokeWeight(5); point(125,35); // left eye point(135,35); // right eye strokeWeight(1); triangle(130,40,140,45,130,45); // nose line(100,90,60,50); // right arm line(60,50,65,40); // right hand line(60,50,57,35); line(60,50,50,48); line(158,76,200,53); // left arm // Stuff that depends on clicks if (mousePressed && dist(mouseX,mouseY,130,40) < 20) { // Top hat in hand rect(40,30,40,5); rect(50,10,20,20); text("Hi there!",155,25); } else { // Top hat on head rect(110,20,40,5); rect(120,0,20,20); } if (mousePressed && dist(mouseX,mouseY,130,90) < 35) { // Wiggle left hand line(200,53,200+random(-5,5),42+random(-5,5)); line(200,53,210+random(-5,5),65+random(-5,5)); } else { // Regular left hand line(200,53,200,42); line(200,53,210,65); } }