/****************************************************** Title: CREEPER Date: 16/9/15 By: Filink Cao ******************************************************/ //set up the size and print an instruction line void setup() { size (400, 400); println ("CREEPER IS FOLLOWING YOU!"); println ("CLICK MOUSE AND IT WILL EXPLODE"); } void draw () { //set the framerate to 30 for draw void frameRate (30); //set the back ground color background (30); //draw a window which changes brightness based on your mouse position colorMode (HSB); fill(61, 21, (abs(mouseX-mouseY)*255/400+40)); rect (165, 50, 70, 40); //draw the floor which changes brightness based on the brightness of the window fill (0, 0, (abs(mouseX-mouseY)*255/400)+50); noStroke(); rect (0, 200, 600, 600); //reset the color mode colorMode (RGB); //the CREEPER rectMode (CENTER); fill (30); //the shadow of CREEPER, changes angles based on the creeper's position quad((mouseX-25)+0.06*abs(200-mouseX)-14, 234, (mouseX-25)+0.06*abs(200-mouseX)+14, 234, 200-1.1*(200-((mouseX-25)+0.06*abs(200-mouseX)+14)), 248, 200-1.1*(200-((mouseX-25)+0.06*abs(200-mouseX)-14)), 248); quad((mouseX+25)-0.06*abs(200-mouseX)-14, 234, (mouseX+25)-0.06*abs(200-mouseX)+14, 234, 200-1.1*(200-((mouseX+25)-0.06*abs(200-mouseX)+14)), 248, 200-1.1*(200-((mouseX+25)-0.06*abs(200-mouseX)-14)), 248); quad(200-1.1*(200-((mouseX-25)+0.06*abs(200-mouseX)+14))-7, 248, 200-1.1*(200-((mouseX+25)-0.06*abs(200-mouseX)+14))-24, 248, (mouseX+14)-0.8*(200-(mouseX+14)), 348, (mouseX-14)-0.8*(200-(mouseX-14)), 348); //the brightside of CREEPER, moves based on the position of creeper colorMode (HSB); fill (61, 21, 91+(abs(mouseX-mouseY)*255/400)); rect (mouseX+0.06*(200-mouseX), 120, 40, 40); rect (mouseX+0.06*(200-mouseX), 160, 25, 100); rect (((mouseX-25)+0.06*(abs(200-mouseX)))+0.06*(200-mouseX), 220, 28, 28); rect (((mouseX+25)-0.06*(abs(200-mouseX)))+0.06*(200-mouseX), 220, 28, 28); //the body of CREEPER colorMode(RGB); fill (10, 50, 0); rect (mouseX, 120, 40, 40); rect (mouseX, 160, 25, 100); //the feet of creeper, the distance between the two feet of creeper decreases when you look at it from the side. rect (((mouseX-25)+0.06*(abs(200-mouseX))), 220, 28, 28); rect (((mouseX+25)-0.06*(abs(200-mouseX))), 220, 28, 28); //the face of CREEPER, the distance between the eyes and the mouth decreases when it looks up or down. fill (0); rect ((mouseX-9)+0.015*(abs(200-mouseX)), 115-0.05*(200-mouseY), 8, 8); rect ((mouseX+9)-0.015*(abs(200-mouseX)), 115-0.05*(200-mouseY), 8, 8); rect (mouseX-0.015*(200-mouseX), 128-0.07*(200-mouseY)-0.02*(abs(190-mouseY)), 8, 12); rect (mouseX-0.015*(200-mouseX)-5, 129-0.07*(200-mouseY)-0.02*(abs(190-mouseY))+3, 5, 12); rect (mouseX-0.015*(200-mouseX)+5, 129-0.07*(200-mouseY)-0.02*(abs(190-mouseY))+3, 5, 12); //the fence and the shadow of the fence rectMode (CORNER); fill (2); noStroke (); rect (0, 0, 10, 250); fill (90); noStroke(); rect (5, 4, 3, 246); fill (30); noStroke(); quad (0, 250, 10, 250, -140.0, 400, -150.0, 400); fill (2); noStroke (); rect (50, 0, 10, 250); fill (90); noStroke(); rect (55, 4, 3, 246); fill (30); noStroke(); quad (50, 250, 60, 250, -55.0, 400, -65.0, 400); fill (2); noStroke (); rect (100, 0, 10, 250); fill (90); noStroke(); rect (105, 4, 3, 246); fill (30); noStroke(); quad (100, 250, 110, 250, 30.0, 400, 20.0, 400); fill (2); noStroke (); rect (150, 0, 10, 250); fill (90); noStroke(); rect (155, 4, 3, 246); fill (30); noStroke(); quad (150, 250, 160, 250, 115.0, 400, 105.0, 400); fill (2); noStroke (); rect (200, 0, 10, 250); fill (90); noStroke(); rect (205, 4, 3, 246); fill (30); noStroke(); quad (200, 250, 210, 250, 200.0, 400, 190.0, 400); fill (2); noStroke (); rect (250, 0, 10, 250); fill (90); noStroke(); rect (255, 4, 3, 246); fill (30); noStroke(); quad (250, 250, 260, 250, 285.0, 400, 275.0, 400); fill (2); noStroke (); rect (300, 0, 10, 250); fill (90); noStroke(); rect (305, 4, 3, 246); fill (30); noStroke(); quad (300, 250, 310, 250, 370.0, 400, 360.0, 400); fill (2); noStroke (); rect (350, 0, 10, 250); fill (90); noStroke(); rect (355, 4, 3, 246); fill (30); noStroke(); quad (350, 250, 360, 250, 455.0, 400, 445.0, 400); fill (2); noStroke (); rect (400, 0, 10, 250); fill (90); noStroke(); rect (405, 4, 3, 246); fill (30); noStroke(); quad (400, 250, 410, 250, 540.0, 400, 530.0, 400); fill (2); noStroke (); rect (450, 0, 10, 250); fill (90); noStroke(); rect (455, 4, 3, 246); fill (30); noStroke(); quad (450, 250, 460, 250, 625.0, 400, 615.0, 400); fill (2); noStroke (); rect (500, 0, 10, 250); fill (90); noStroke(); rect (505, 4, 3, 246); fill (30); noStroke(); quad (500, 250, 510, 250, 710.0, 400, 700.0, 400); fill (2); noStroke (); rect (550, 0, 10, 250); fill (90); noStroke(); rect (555, 4, 3, 246); fill (30); noStroke(); quad (550, 250, 560, 250, 795.0, 400, 785.0, 400); fill (2); noStroke (); rect (600, 0, 10, 250); fill (90); noStroke(); rect (605, 4, 3, 246); fill (30); noStroke(); quad (600, 250, 610, 250, 880.0, 400, 870.0, 400); } //the creeper explode when mouse pressed void mousePressed () { //set the frame rate frameRate (1); //redraw the background background (30); colorMode (HSB); fill(61, 21, (abs(mouseX-mouseY)*255/400+40)); rect (165, 50, 70, 40); //redraw the ground colorMode (HSB); fill (0, 0, (abs(mouseX-mouseY)*255/400)+50); noStroke(); rect (0, 200, 600, 600); colorMode (RGB); //reset the rect mode rectMode (CORNER); //redraw the fence fill (2); noStroke (); rect (0, 0, 10, 250); fill (90); noStroke(); rect (5, 4, 3, 246); fill (30); noStroke(); quad (0, 250, 10, 250, -140.0, 400, -150.0, 400); fill (2); noStroke (); rect (50, 0, 10, 250); fill (90); noStroke(); rect (55, 4, 3, 246); fill (30); noStroke(); quad (50, 250, 60, 250, -55.0, 400, -65.0, 400); fill (2); noStroke (); rect (100, 0, 10, 250); fill (90); noStroke(); rect (105, 4, 3, 246); fill (30); noStroke(); quad (100, 250, 110, 250, 30.0, 400, 20.0, 400); fill (2); noStroke (); rect (150, 0, 10, 250); fill (90); noStroke(); rect (155, 4, 3, 246); fill (30); noStroke(); quad (150, 250, 160, 250, 115.0, 400, 105.0, 400); fill (2); noStroke (); rect (200, 0, 10, 250); fill (90); noStroke(); rect (205, 4, 3, 246); fill (30); noStroke(); quad (200, 250, 210, 250, 200.0, 400, 190.0, 400); fill (2); noStroke (); rect (250, 0, 10, 250); fill (90); noStroke(); rect (255, 4, 3, 246); fill (30); noStroke(); quad (250, 250, 260, 250, 285.0, 400, 275.0, 400); fill (2); noStroke (); rect (300, 0, 10, 250); fill (90); noStroke(); rect (305, 4, 3, 246); fill (30); noStroke(); quad (300, 250, 310, 250, 370.0, 400, 360.0, 400); fill (2); noStroke (); rect (350, 0, 10, 250); fill (90); noStroke(); rect (355, 4, 3, 246); fill (30); noStroke(); quad (350, 250, 360, 250, 455.0, 400, 445.0, 400); fill (2); noStroke (); rect (400, 0, 10, 250); fill (90); noStroke(); rect (405, 4, 3, 246); fill (30); noStroke(); quad (400, 250, 410, 250, 540.0, 400, 530.0, 400); fill (2); noStroke (); rect (450, 0, 10, 250); fill (90); noStroke(); rect (455, 4, 3, 246); fill (30); noStroke(); quad (450, 250, 460, 250, 625.0, 400, 615.0, 400); fill (2); noStroke (); rect (500, 0, 10, 250); fill (90); noStroke(); rect (505, 4, 3, 246); fill (30); noStroke(); quad (500, 250, 510, 250, 710.0, 400, 700.0, 400); fill (2); noStroke (); rect (550, 0, 10, 250); fill (90); noStroke(); rect (555, 4, 3, 246); fill (30); noStroke(); quad (550, 250, 560, 250, 795.0, 400, 785.0, 400); fill (2); noStroke (); rect (600, 0, 10, 250); fill (90); noStroke(); rect (605, 4, 3, 246); fill (30); noStroke(); quad (600, 250, 610, 250, 880.0, 400, 870.0, 400); //to make it looks like the fence is blown off by the explosion, I simply draw a rectangle on the top of fence and a quad on top of the ground. rectMode (CENTER); fill (30); rect (mouseX, 150, 120, 100); colorMode (HSB); fill (0, 0, (abs(mouseX-mouseY)*255/400)+50); rect (mouseX, 210, 120, 20); fill (0, 0, (abs(mouseX-mouseY)*255/400)+50); quad (mouseX-60, 300, mouseX+60, 300, (200 - 1.24*(200-(mouseX+60))), 370, (200 - 1.24*(200-(mouseX-60))), 370); colorMode (RGB); //the explosion fill (255); ellipse (mouseX-20, 120, 30, 30); fill (30); ellipse (mouseX-10, 115, 20, 20); fill (255); ellipse (mouseX+10, 150, 60, 60); fill (30); ellipse (mouseX-3, 167, 40, 40); fill (255); ellipse (mouseX-13, 200, 36, 36); ellipse (mouseX-40, 110, 20, 20); fill (30); ellipse (mouseX-43, 107, 15, 15); fill (255); ellipse (mouseX+30, 160, 40, 40); ellipse (mouseX-40, 178, 57, 57); ellipse (mouseX, 220, 34, 34); ellipse (mouseX+5, 190, 23, 23); fill (30); ellipse (mouseX+45, 160, 26, 26); ellipse (mouseX-50, 190, 30, 30); }