//--------------------Assignment 1-------------------------- //----------Introduction to Media Computation--------------- //--------------Project: Stormy Night----------------------- //----------------By: Abdullah Allami----------------------- /* In the stormy night, the detctive is investigating a murder! Lightening hits the ground as he inspects the blood of the victim -------------------------------------------------- Instructions: Moving the mouse up will point the flashlight up Moving the mouse down will point the flashlight down pressing the mouse will call down lightening The position of the lightening is based on the mouse, you can move it to the left or right Note: The blood is animated */ void setup() { size(400, 400); } void draw() { //Background color background(10, 10, 50); // Bridge color fill(1, 1, 40); // the thick stroke will be used to make the bridge appear to have a top surface stroke(40, 40, 60); strokeWeight(20); //Bridge base shape rect(-10, 300, 420, 100); // Support structure strokeWeight(10); rect(370, 90, 120, 210); // Pipe ellipse(380, 100, 20, 20); //Bridge under arc Color fill(10, 10, 50); strokeWeight(10); //Bridge arcs ellipse(100, 400, 80, 140); ellipse(200, 400, 80, 140); ellipse(300, 400, 80, 140); //Blood-------------------------------------------------------------------- // Blood stream strokeWeight(4); stroke(50, 0, 0); line(380, 300, 380, 100); // Blood pool fill(50, 0, 0); ellipse(380, 300, 40, 16); // Blood pool animation stroke(60, 10, 10); strokeWeight(4); ellipse(380, 300, .25*(frameCount%80), .1*(frameCount%80)); //Blood line animation line(380, 100+(frameCount%200), 380, 105+(frameCount%200)); line(380, 100+((frameCount+50)%200), 380, 105+((frameCount+50)%200)); line(380, 100+((frameCount+100)%200), 380, 105+((frameCount+100)%200)); // Flash Light--------------------------------------------------------- // Flash Light color noStroke(); fill(200, 200, 200, 100); // Flashlight shape. // Flashlight can point up or down triangle(150, 255, 500, mouseY+100, 500, mouseY-100); // Detective Character------------------------------------------------------- //face stroke(246, 210, 170); fill(255, 220, 177); ellipse(130, 210, 20, 20); // Suit and hat color stroke(5, 0, 0); fill(5, 0, 0); // Hat rect(120, 170, 20, 30); ellipse(130, 200, 40, 20); //Body rect(120, 220, 20, 40); // Hands triangle(150, 250, 140, 220, 150, 220); triangle(110, 250, 120, 220, 110, 220); // Legs rect(120, 260, 5, 40); rect(135, 260, 5, 40); // Feet triangle(120, 300, 130, 300, 120, 290); triangle(135, 300, 145, 300, 135, 290); } void mousePressed() { // When mouse is pressed there will be a lightening strike //Background color when lightning strikes background(100, 100, 150); // Render lightening -------------------------------------------- // Lightening color stroke(255, 255); strokeWeight(3); // Lightening shape line(mouseX-10, 0, mouseX+10, 30); line(mouseX+10, 30, mouseX-10, 60); line(mouseX-10, 60, mouseX+10, 90); line(mouseX+10, 90, mouseX-10, 120); line(mouseX-10, 120, mouseX+10, 150); line(mouseX+10, 150, mouseX-10, 180); line(mouseX-10, 180, mouseX+10, 210); line(mouseX+10, 210, mouseX-10, 240); line(mouseX-10, 240, mouseX+10, 270); line(mouseX+10, 270, mouseX-10, 290); // Brightening the colors of the enviroment------------------------------- // Bridge color when lightning strikes strokeWeight(1); fill(60, 60, 90); stroke(200, 200, 250); // the thick stroke will be used to make the bridge appear to have a top surface strokeWeight(20); //Bridge base shape rect(-10, 300, 420, 100); // Support structure strokeWeight(10); rect(370, 90, 120, 210); // Pipe ellipse(380, 100, 20, 20); //Bridge under arc Color when lightning strikes fill(100, 100, 150); strokeWeight(10); //Bridge arcs ellipse(100, 400, 80, 140); ellipse(200, 400, 80, 140); ellipse(300, 400, 80, 140); // Flash Light-------------------------------------------------- // Flash Light color noStroke(); fill(100, 100, 100, 100); // Flashlight shape. // Flashlight can point up or down triangle(150, 245, 500, mouseY+100, 500, mouseY-100); // Detective Character When Lightening strikes---------------------------------------------- //face //stroke(246, 210, 170); strokeWeight(1); fill(255, 220, 177); ellipse(130, 210, 20, 20); // Suit and hat color stroke(130, 130, 130); fill(130, 130, 130); // Hat rect(120, 170, 20, 30); ellipse(130, 200, 40, 20); //Body rect(120, 220, 20, 40); // Hands triangle(150, 250, 140, 220, 150, 220); triangle(110, 250, 120, 220, 110, 220); // Legs rect(120, 260, 5, 40); rect(135, 260, 5, 40); // Feet triangle(120, 300, 130, 300, 120, 290); triangle(135, 300, 145, 300, 135, 290); }