/* Title: Subway Train By: Quinn Goffin Date Submitted: September 21, 2016 Description: The train will follow your mouse left or right (handle bars in the train will sway to the motion). Moving your mouse up will cause the platform lights to dim, and the trains lights to brighten (allowing for visibility into the trains window). Moving your mouse down willcause the trains lights to dim (making its windows opaque) and brightening the platforms lights. Clicking the mouse or pressing any key will open the train door. */ void setup() { size(400, 400); } void draw() { frameRate(60); background(20); //Train, moves with X coordinates of mouse, windows change oppacity based on Y coordinates of mouse //Body noStroke(); fill(109, 113, 118); rect(mouseX, 90, 400, 170, 8); strokeWeight(1.5); stroke(25); line(mouseX+10, 200, mouseX+400, 200); line(mouseX+10, 210, mouseX+400, 210); line(mouseX+10, 220, mouseX+400, 220); //Doors stroke(0); fill(92, 95, 98); rect(mouseX+40, 100, 80, 150, 2); strokeWeight(0); line(mouseX+80, 105, mouseX+80, 245); //Door Windows fill(248, 255, 173); rect(mouseX+60, 120, 10, 40, 2); rect(mouseX+90, 120, 10, 40, 2); fill(0, 0, 100, mouseY/2); rect(mouseX+60, 120, 10, 40, 2); rect(mouseX+90, 120, 10, 40, 2); //Door Handles noFill(); rect(mouseX+65, 170, 5, 10, 2); rect(mouseX+90, 170, 5, 10, 2); //Window (Inside) fill(248, 255, 173); rect(mouseX+165, 115, 110, 70, 2); fill(214, 41, 44); rect(mouseX+165, 160, 110, 25); line(mouseX+195, 165, mouseX+195, 185); line(mouseX+245, 165, mouseX+245, 185); //Handles/ Pole (Inside), sway with the movement of the train fill(100); rect(mouseX+165, 125, 110, 4); strokeWeight(3); stroke(100); line(mouseX+180, 130, pmouseX+180, 140); line(mouseX+260, 130, pmouseX+260, 140); line(mouseX+220, 130, pmouseX+220, 140); //Return strokeWeight to original value strokeWeight(1.5); //Window fill(47, 62, 113, (mouseY/1.1)-40); rect(mouseX+165, 115, 110, 70, 2); //Platform, brightness adjusted bassed on Y coordinates of mouse //Floor noStroke(); fill(135, 137, 125); rect(0, 260, 400, 140); //Ceiling fill(113, 118, 72); rect(0, 0, 400, 80); //Pillars noStroke(); fill(184, 193, 117); rect(40, 60, 40, 250); rect(320, 60, 40, 250); fill(152, 160, 95); quad(80, 60, 90, 70, 90, 270, 80, 307); quad(320, 60, 320, 307, 310, 270, 310, 70); //Lights strokeWeight(1.5); fill(224, 236, 255, 50+(mouseY/5)); stroke(50); strokeWeight(1); quad(-10, 0, 20, 0, 60, 40, 30, 40); quad(410, 0, 370, 40, 340, 40, 380, 0); quad(215, 0, 210, 40, 180, 40, 175, 0); //Light beams noStroke(); fill(224, 236, 255, 10+(mouseY/5)); triangle(30, 20, 110, 340, -80, 340); triangle(195, 15, 275, 335, 115, 335); triangle(370, 20, 460, 340, 280, 340); } void mousePressed() { frameRate(1); //Train door open, inside of train noStroke(); fill(248, 255, 173); rect(mouseX+41, 101, 79, 149, 2); fill(189, 191, 201); rect(mouseX+41, 200, 79, 50); fill(0, 0, 0, 15); rect(mouseX+41, 190, 79, 20); //Pillars, redrawn to prevent inside of train from being ontop of pillars fill(184, 193, 117); rect(40, 60, 40, 250); rect(320, 60, 40, 250); fill(152, 160, 95); quad(80, 60, 90, 70, 90, 270, 80, 307); quad(320, 60, 320, 307, 310, 270, 310, 70); } void keyPressed() { frameRate(1); //Train door open, inside of train noStroke(); fill(248, 255, 173); rect(mouseX+41, 101, 79, 149, 2); fill(189, 191, 201); rect(mouseX+41, 200, 79, 50); fill(0, 0, 0, 15); rect(mouseX+41, 190, 79, 20); //Pillars, redrawn to prevent inside of train from being ontop of pillars fill(184, 193, 117); rect(40, 60, 40, 250); rect(320, 60, 40, 250); fill(152, 160, 95); quad(80, 60, 90, 70, 90, 270, 80, 307); quad(320, 60, 320, 307, 310, 270, 310, 70); }