/* Introduction to Media Computation: Interactive Drawing Assignment 09/2018 By Roberto Rosales "Be the Spartan" Pretty simple interactions, you hold an MA5C Assault Rifle that moves with the mouse to a certain degree. Click on the mouse to shoot, press a key to get hit. Don't worry, your shields will regenerate automatically. PS. Those Covenant ships are too far away to shoot, but you can always try. */ void setup() { // Set the size of window & remove cursor size (400, 400); noCursor(); } void draw() { // Set framerate to 60 frameRate(60); // BACKGROUND STUFF // Make background green (pretty irrelevant because we'll just draw gradients over it) background(80, 230, 170); // Start drawing the background gradients // 1st, bottom, darkest noStroke(); fill(70, 192, 144); rectMode(CENTER); rect(200, 240, 400, 30); // 2nd fill(70, 200, 150); rect(200, 210, 400, 30); // 3rd fill(74, 212, 155); rect(200, 180, 400, 30); // 4th fill(84, 225, 170); rect(200, 150, 400, 30); // 5th fill(88, 234, 178); rect(200, 120, 400, 30); // 6th fill (96, 244, 186); rect(200, 90, 400, 30); // 7th fill(140, 245, 198); rect(200, 60, 400, 30); // 8th, top, lightest fill(180, 248, 222); rect(200, 20, 400, 50); // COVENANT FLEET STUFF // Covenant Assault Carrier (Biggest ship) fill(110, 100, 105); // Main structure ellipse(501 - (frameCount % 1000), 49, 60, 40); ellipse(495 - (frameCount % 1000), 50, 65, 40); ellipse(526 - (frameCount % 1000), 42, 21, 20); // Deck ellipse(520 - (frameCount % 1000), 67, 70, 6); // Bridge ellipse(550 - (frameCount % 1000), 35, 140, 11); // Mid section ellipse(600 - (frameCount % 1000), 45, 65, 25); ellipse(588 - (frameCount % 1000), 55, 60, 6); // Fire fill(100, 210, 255); ellipseMode(CORNER); ellipse(628 - (frameCount % 1000), 45, random(685-655), 10); // Tail fill(120, 95, 115); ellipseMode(CENTER); ellipse(635 - (frameCount % 1000), 40, 30, 10); // Covenant Battlecruisers (smaller ships) // Main structure fill(120, 95, 115); ellipseMode(CENTER); ellipse(402 - (frameCount % 1000), 100, 15, 10); // Bridge ellipse(420 - (frameCount % 1000), 97, 40, 5); // Mid Section ellipse(435 - (frameCount % 1000), 101, 35, 12); // Tail ellipse(451 - (frameCount % 1000), 99, 15, 5); // "Teeth" triangle(396 - (frameCount % 1000), 100, 402 - (frameCount % 1000), 110, 401 - (frameCount % 1000), 100); triangle(400 - (frameCount % 1000), 100, 406 - (frameCount % 1000), 108, 408 - (frameCount % 1000), 100); // Fire fill(100, 210, 255); ellipseMode(CORNER); ellipse(452 - (frameCount % 1000), 100, random(468-456), 5); // TREES & STUFF // Left tree fill(40, 40, 20); // Main trunk // left bot/right bot/right top/left top quad(50, 400, 140, 400, 130, 0, 70, 0); // Secondary trunk(?) // left bot / top / right bot triangle(-30, 238, 40, 170, 80, 238); // left bot/right bot/right top/left top quad(15, 238, 55, 238, 35, 0, 15, 0); // Right tree // Main trunk // ( left bot / top / right bot) triangle(340, 238, 320, -150, 430, 238); triangle(300, 250, 400, 90, 400, 238); // Branches // left bot / left top/right top/right bot quad(340, 150, 290, 100, 315, 96, 340, 115); triangle(290, 100, 280, -150, 315, 97); // CLOUDS STUFF /* Clouds Honestly I just messed randomly with the cos and sin functions until I got a result I liked */ fill(0, 0, 0, 100); ellipseMode(CENTER); ellipse(320 + cos(frameCount/50.0)*10, 260 + sin(frameCount/150.0)*10, 300, 100); ellipse(49 + sin(frameCount/50.0)*10, 250 + cos(frameCount/150.0)*10, 248, 150); fill(20, 20, 20, 60); ellipse(180 + sin(frameCount/50.0)*10, 300 + sin(frameCount/100.0)*10, 140, 200); ellipse(360 + cos(frameCount/50.0), 300 + cos(frameCount/100.0)*10, 220, 220); // FLOOR & WALL STUFF // Draw background floor noStroke(); fill(150, 150, 150); rectMode(CORNERS); rect(0, 300, 400, 400); // Draw first background structure fill(180); rect(0, 252, 400, 300); // Floor/wall line-shadow stroke(40); strokeWeight(2); line(0, 300, 400, 300); // Draw secondary structures, "bumps" // Bump 1 noStroke(); fill(200); rect(0, 238, 100, 300); // Bump1 shadow fill(100); rect(100, 252, 104, 300); // Bump 2 noStroke(); fill(200); rect(300, 238, 400, 300); // Bump2 shadow fill(100); rect(300, 252, 296, 300); // ASSAULT RIFLE & ARM STUFF // Palm noStroke(); fill(20); // ( Left bottom / Right bottom / Left top / Right top ) quad(mouseX/20+290, mouseY/15+335, mouseX/20+330, mouseY/15+355, mouseX/20+360, mouseY/15+315, mouseX/20+315, mouseY/15+295); // Receiver top fill(140); // ( Right top / Left top / Left bottom / Right bottom ) quad(mouseX/20+295, mouseY/9+222, mouseX/20+275, mouseY/7+225, mouseX/20+262, mouseY/7+250, mouseX/20+280, mouseY/8+260); // Green led stroke(100, 255, 100); strokeWeight(3); line(mouseX/20+280, mouseY/7+248, mouseX/20+282, mouseY/7+243); // Receiver bottom noStroke(); fill(70); // ( Left top / Left bottom / Right bottom / Right top ) quad(mouseX/20+262, mouseY/7+250, mouseX/20+275, mouseY/8+300, mouseX/20+295, mouseY/8+305, mouseX/20+280, mouseY/8+260); // Barrel top fill(130); // ( Left top / Right top / Right bottom / Left bottom ) quad(mouseX/20+280, mouseY/8+260, mouseX/20+340, mouseY/11+268, mouseX/20+400, mouseY/40+305, mouseX/20+400, 340); stroke(140); line(mouseX/20+280, mouseY/8+260, mouseX/20+400, 340); // Barrel bottom fill(130); // ( Left top / Right top / Right bottom / Left bottom ) quad(mouseX/20+280, mouseY/8+259, mouseX/20+400, 340, mouseX/20+400, 380, mouseX/20+285, mouseY/8+299); strokeWeight(13);{ stroke(70);} line(mouseX/20+280, mouseY/8+292, mouseX/20+325, mouseY/12+322); // Stock fill(80); // ( Bottom left / Top / Bottom right ) triangle(mouseX/20+380, mouseY/25+317, mouseX/20+410, 305, mouseX/20+410, 340); // Ammo Counter base noStroke(); fill(140); // ( Left top / Rigt top / Right bottom / Left bottom ) quad(mouseX/20+295, mouseY/9+222, mouseX/20+325, mouseY/10+224,mouseX/20+340, mouseY/11+268, mouseX/20+280, mouseY/8+260); // Ammo counter screen strokeWeight(2); stroke(110); fill(120, 140, 160); // ( Left top / Rigt top / Right bottom / Left bottom ) quad(mouseX/20+300, mouseY/8+224, mouseX/20+320, mouseY/9+227, mouseX/20+330, mouseY/10+260, mouseX/20+290, mouseY/8+255); // Flickering screen fill(120, 160, 190, tan(frameCount)*100); quad(mouseX/20+300, mouseY/8+224, mouseX/20+320, mouseY/9+227, mouseX/20+330, mouseY/10+260, mouseX/20+290, mouseY/8+255); // Bullet counter display noFill(); stroke(74, 255, 253, tan(frameCount)*1000); strokeWeight(1); // ( Left bottom / Right top / Right bottom / Left top ) quad(mouseX/20+300, mouseY/9+245, mouseX/20+318, mouseY/9+235, mouseX/20+320, mouseY/9+245, mouseX/20+302, mouseY/8.8+235); // Hand & Arm // Thumb noStroke(); fill(30); // ( Right top / Right bottom / Left bottom / Left top ) quad(mouseX/20+300, mouseY/15+305, mouseX/20+310, mouseY/15+335, mouseX/20+290, mouseY/15+335, mouseX/20+290, mouseY/15+295); // Basic forearm fill(20); // ( Left top / Right top / Right bottom / Left bottom ) quad(mouseX/20+290, mouseY/15+335, mouseX/20+330, mouseY/15+355, mouseX/20+310, mouseY/15+395, mouseX/20+255, mouseY/15+395); // Forearm armor fill(60, 80, 150); // ( Left top / Right top / Right bottom / Left bottom ) quad(mouseX/20+280, mouseY/15+340, mouseX/20+330, mouseY/15+375, mouseX/20+322, mouseY/15+405, mouseX/20+240, mouseY/15+405); // Forearm armor shadow fill(40, 40, 40, 200); // ( Left top / Right top / Right bottom / Left bottom ) quad(mouseX/20+296, mouseY/15+352, mouseX/20+310, mouseY/15+360, mouseX/20+295, mouseY/15+405, mouseX/20+270, mouseY/15+405); // HUD STUFF // Top blue edge stroke(74, 255, 253, 160); strokeWeight(2); fill(74, 255, 253, 30); ellipse(width/2, -15, 500, 100); // Bottom blue edge // Center noStroke(); fill(74, 255, 253, 30); rectMode(CENTER); rect(width/2, 395, 330, 20); // Right corner fill(74, 255, 253, 30); quad(365, 385, 500, 270, 500, 400, 365, 410); // Left corner fill(74, 255, 253, 30); quad(35, 385, -100, 270, -100, 400, 35, 410); // Outline stroke(74, 255, 253, 160); line(-100, 270, 35, 385); line(35, 385, 365, 385); line(365, 385, 500, 270); // Shield's bar stroke(74, 255, 253, 160); fill(74, 255, 253, 60); rect(width/2, 20, 100, 10); // Outline stroke(255, 255, 255, 100); rect(200, 20, 105, 15); // Radar // Basic shape stroke(74, 255, 253, 140); fill(74, 255, 253, 60); ellipseMode(CENTER); ellipse(50, 340, 90, 70); // Center dot noStroke(); fill(255, 255, 255, 220); ellipse(50, 340, 4, 2); // Enemy movement (red dots) noStroke(); fill(240, 0, 0, 160); ellipse(70 + cos(frameCount/40.0)*10, 340 + sin(frameCount/25.0)*5, 4, 2); fill(240, 0, 0, 160); ellipse(20 + sin(frameCount/25.0)*10, 335 + cos(frameCount/50.0)*5, 4, 2); // Crosshair noFill(); stroke(74, 255, 255); strokeWeight(2); ellipseMode(CENTER); ellipse(mouseX, mouseY, 20, 20); line(mouseX+10,mouseY,mouseX+5,mouseY); line(mouseX-10,mouseY,mouseX-5,mouseY); line(mouseX,mouseY+10,mouseX,mouseY+5); line(mouseX,mouseY-10,mouseX,mouseY-5); } // SHOOTING STUFF void mousePressed() { println("Pew"); // Firing lines stroke(255, 255, 70); strokeWeight(3); line(mouseX, mouseY, mouseX/20+262, mouseY/7+250); line(mouseX/20+262, mouseY/7+250, mouseX-random(15-5), mouseY-random(16-7)); line(mouseX/20+262, mouseY/7+250, mouseX+random(15-5), mouseY+random(18-9)); } // When key is pressed you get hit and shields regenerate void keyPressed() { println("AAHHHHH"); frameRate(3); // Shield taking damage fill(255, 70, 70, 200); rect(200, 20, 100, 10); // Red stuff from getting shot noStroke(); ellipse(-275, height/2, 600, 1000); ellipse(675, height/2, 600, 1000); // This is just the previous seen "Bottom blue edge" of "HUD STUFF", but in red rect(200, 395, 330, 20); // Right corner quad(365, 385, 500, 270, 500, 400, 365, 410); // Left corner quad(35, 385, -100, 270, -100, 400, 35, 410); // Outline stroke(74, 255, 253, 160); line(-100, 270, 35, 385); line(35, 385, 365, 385); line(365, 385, 500, 270); }