xxxxxxxxxx
71
var hatSize = 0;
function setup() {
createCanvas(1000, 1000);
}
function draw() {
background("lightblue");
//
strokeWeight(5);
fill("red");
textSize(24);
textStyle(BOLD);
textAlign(CENTER);
text("CLICK SOMEWHERE ON THE ELF TO BE SURPRISED, YOU HAVE 3 ATTEMPTS",500,300);
//
strokeWeight(2);
fill("lightgreen");
ellipse(350, 770, 50, 50); // ear one
strokeWeight(2);
fill("lightgreen");
ellipse(650, 770, 50, 50); // ear two
fill("lightgreen");
strokeWeight(5);
ellipse(500, 800, 300, 300); // head
strokeWeight(3);
fill("black");
ellipse(450, 750, 20, 20); // eye one
strokeWeight(3);
fill("black");
ellipse(550, 750, 20, 20); // eye two
strokeWeight(5);
fill("red");
triangle(380, 700, 620, 700, 500, 400); // hat
strokeWeight(6);
fill("white");
ellipse(500, 400, 80 + hatSize, 80 + hatSize);
// hat tip
strokeWeight(5);
ellipse(500, 800, 20, 20); // mouth
strokeWeight(5);
triangle(500, 860, 420, 840, 580, 840);
if (hatSize >= 10) {
strokeWeight(5);
stroke("yellow");
fill("red");
textSize(24);
textStyle(BOLD);
textAlign(CENTER);
text("MERRY CHRISTMAS AND A HAPPY NEW YEAR!", width / 2, height - 20);
}
}
function mousePressed() {
// Check if the mouse is over the hat
var d = dist(mouseX, mouseY, 500, 400);
if (d < 40 + hatSize / 2) {
hatSize += 10;
}
}