/* ___________________________________________________ Creator: CJ O'Heany Introduction to Media Computation October 1, 2018 Instructor: Nicolas Hesler ___________________________________________________ Step 1. Click your mouse as much as possible Step 2. ??? Step 3. Profit ___________________________________________________ */ //Variables int backColour = 255; int cloudCount = 0; int cloudCount2 = 90; int noseBleedCount = 0; int crackCount = 0; int bloodLevel =0; boolean clicked = false; boolean readyToRise = false; void setup() { size(400, 400); } void draw() { //Sets the background in draw to allow for later drawings background(backColour); //See the listed methods for their effects drawDesk(); drawClouds(); addingCracks(); drawGuy(); drawBloodPool(); } void mousePressed() { //Clicked is set true here clicked = true; //Nose bleed is extended too noseBleedCount +=5; //The readyToRise boolean is set true here if (noseBleedCount >=255) { readyToRise = true; } //Now that readyToRise is true, the level of the blood will increase if (readyToRise) { bloodLevel+=2; } } void mouseReleased() { //The reciprocal of clicked, allowing for the guy to rise back up clicked = false; } void mouseClicked() { //This is the variable that allows for all the cracks crackCount +=1; } //The adding cracks method simply checks the "crackCount" variable and draws things //based on the value of "crackCount". void addingCracks() { noStroke(); fill(25); //Draws the first 4 triangle (Cracks) if (crackCount >= 1) { triangle(320, 340, 360, 320, 378, 322); triangle(320, 340, 360, 350, 360, 340); triangle(320, 340, 280, 380, 270, 370); triangle(320, 340, 240, 340, 245, 350); } //Extends the triangles and adds new ones if (crackCount>= 2) { triangle(360, 320, 378, 322, 392, 300); triangle(360, 350, 360, 340, 410, 355); triangle(280, 380, 270, 370, 260, 410); triangle(280, 380, 270, 370, 160, 370); triangle(240, 340, 245, 350, 200, 345); triangle(320, 340, 360, 290, 350, 280); } //Extends the triangles and adds new ones if (crackCount>=3) { triangle(378, 322, 392, 300, 410, 310); triangle(170, 370, 90, 390, 85, 380); triangle(210, 345, 160, 340, 170, 330); triangle(360, 290, 350, 280, 362, 255); triangle(320, 340, 250, 280, 280, 290); } //Extends the triangles and adds new ones if (crackCount>=4) { triangle(90, 390, 85, 380, 50, 390); triangle(160, 340, 170, 330, 150, 323); triangle(250, 280, 280, 290, 255, 268); triangle(320, 340, 350, 390, 360, 385); } ////Extends the triangles and adds cracks to the walls if (crackCount>=5) { triangle(50, 390, 55, 400, 50, 400); triangle(350, 390, 360, 385, 370, 410); triangle(376, 263, 380, 270, 377, 244); triangle(130, 333, 120, 340, 120, 314); } //Extends the triangles on the walls if (crackCount>=6) { triangle(378, 250, 356, 203, 370, 200); triangle(123, 316, 93, 281, 80, 280); triangle(123, 316, 147, 274, 153, 283); triangle(10, 400, 20, 400, 11, 355); } //Extends the triangles on the walls and adds new ones if (crackCount>=7) { triangle(356, 203, 370, 200, 348, 180); triangle(93, 281, 80, 280, 40, 247); triangle(147, 274, 153, 283, 180, 230); triangle(11, 365, 30, 244, 20, 256); } //Extends the triangles on the walls and adds new ones if (crackCount>=8) { triangle(45, 251, 40, 247, 50, 144); triangle(177, 234, 164, 180, 150, 192); triangle(30, 244, 20, 256, -10, 181); //The fill changes here as I am drawing on the glass fill(200); triangle(348, 180, 312, 141, 305, 150); } //Extends the cracks on the walls and adds new ones if (crackCount>=9) { //All these triangles are on the windows triangle(312, 141, 305, 150, 321, 103); triangle(312, 141, 305, 150, 273, 118); triangle(312, 141, 305, 150, 257, 152); //Resets the triangles' fill colour to the walls fill(25); triangle(50, 155, 124, 91, 120, 80); triangle(50, 155, -10, 61, -10, 50); triangle(164, 180, 150, 192, 180, 111); triangle(123, 316, 100, 217, 110, 207); } //Extends cracks on the walls if (crackCount>=10) { triangle(124, 91, 120, 80, 155, -10); triangle(180, 110, 164, 34, 170, 25); triangle(100, 217, 110, 207, 65, 100); triangle(100, 217, 110, 207, 148, 100); //Sets the fill for the windows fill(200); triangle(263, 150, 248, 180, 240, 180); triangle(280, 118, 223, 130, 230, 137); triangle(280, 118, 250, 80, 240, 80); triangle(321, 113, 306, 80, 314, 80); } //Extends some more cracks on the walls and windows if (crackCount>=11) { triangle(223, 130, 230, 137, 180, 163); triangle(223, 130, 230, 137, 207, 180); //Resets the fill back to that for the walls fill(25); triangle(248, 180, 240, 180, 234, 277); triangle(250, 80, 240, 80, 210, -10); triangle(250, 80, 240, 80, 291, -5); triangle(306, 80, 314, 80, 347, 20); triangle(164, 34, 170, 25, 219, -5); triangle(65, 110, 100, -10, 110, -10); } //Last extending triangles for the walls if (crackCount >=12) { triangle(347, 20, 348, -5, 358, -5); triangle(347, 20, 410, 20, 410, 30); } } //This is the method which has the clouds moving side to side void drawClouds() { //CloudCount is simply the modifier that allows for the cloud to move cloudCount+=1; //Draws the window rectMode(CORNERS); fill(200, 220, 245); rect(180, 80, 360, 180); //Draws the clouds and modifies it with the cloudCount. //CloudCount2 is the vertical movement that has the illusion of //different clouds passing by fill(255); noStroke(); ellipse(400-cloudCount, cloudCount2, 25, 25); ellipse(380-cloudCount, cloudCount2, 25, 25); ellipse(390-cloudCount, cloudCount2-10, 20, 20); //Redraws the lines to show the window more clearly stroke(0); line(180, 80, 360, 80); line(180, 80, 180, 180); line(180, 180, 360, 180); line(360, 80, 360, 180); //Resets the clouds position on the X-axis //Sets the cloud down 20px if (cloudCount >= 240) { cloudCount=0; cloudCount2 += 20; //resets the cloud when it moves down enough if (cloudCount2 >= 200) { cloudCount2 = 90; } } } //Draw guy draws two versions of the guy //1 being him sitting up //2 having the guy smash his head into the desk void drawGuy() { //Standing up if (clicked == false) { stroke(0); //Draws the shirt fill(235, 90, 100); triangle(140, 200, 230, 160, 260, 160); noStroke(); quad(140, 200, 260, 160, 260, 266, 140, 328); stroke(0); line(260, 160, 260, 266); line(140, 200, 140, 328); line(250, 200, 250, 268); line(160, 240, 160, 320); //Draws the head fill(255, 225, 200); ellipseMode(CENTER); ellipse(width/2, height/2 -40, 80, 80); //Draws the facial features line(230, 160, 180, 180); fill(0); ellipse(180, 160, 5, 5); ellipse(220, 145, 5, 5); //Draws the nosebleed that extends noStroke(); fill(255, 50, 50); quad(190, 160, 190, 175+noseBleedCount, 195, 172+noseBleedCount, 195, 155); //If the mouse is pressed } else { //Draws the shirt stroke(0); fill(235, 90, 100); triangle(260, 380, 290, 370, 360, 300); noStroke(); quad(262, 380, 362, 300, 270, 260, 140, 320); stroke(0); line(262, 380, 140, 320); line(362, 300, 270, 260); line(270, 260, 140, 320); line(340, 300, 260, 265); line(260, 360, 160, 310); fill(255, 225, 200); //Draws the head ellipseMode(CENTER); ellipse(320, 340, 80, 80); } } void drawDesk() { //Draw the desk stroke(0); fill(170, 85, 30); quad(330, 230, 560, 400, 60, 400, 40, 380); //Adds depth fill(100, 50, 20); triangle(40, 380, 60, 400, 40, 400); } //Draws the blood pool after the nose bleed has extended enough void drawBloodPool() { //This is the payoff for the readyToRise boolean //If it's true, draws the bloody pool if (readyToRise == true) { //Sets the colour to red fill(255, 50, 50); rectMode(CORNERS); noStroke(); //the sin(frameCount/10) allows for the pool to move up and down rect(0, 400-bloodLevel+ sin(frameCount/10), 400, 400); } }