/* File Name: Car go fast By: Colin Biliau Description: Move the mouse from left to right to move the car and click and hold to make it night time and turn on the headlights Release mouse to return to day */ void setup () { size (400, 400); } void draw () { frameRate(60); background(75, 175, 229); //set fill colour to yellow fill(255, 255, 0); ellipse(350, 50, 30, 30); fill(255, 255, 0, 105); ellipse(350, 50, 40, 40); //set fill colour to pale green fill(24, 94, 29); //Big Trees in the back triangle(-mouseX/20+205, 200, -mouseX/20+240, 150, -mouseX/20+275, 200); triangle(-mouseX/20+205, 230, -mouseX/20+240, 180, -mouseX/20+275, 230); triangle(-mouseX/20+205, 260, -mouseX/20+240, 210, -mouseX/20+275, 260); triangle(-mouseX/20+75, 200, -mouseX/20+110, 150, -mouseX/20+145, 200); triangle(-mouseX/20+75, 230, -mouseX/20+110, 180, -mouseX/20+145, 230); triangle(-mouseX/20+75, 260, -mouseX/20+110, 210, -mouseX/20+145, 260); triangle(-mouseX/5+275, 200, -mouseX/5+310, 150, -mouseX/5+345, 200); triangle(-mouseX/5+275, 230, -mouseX/5+310, 180, -mouseX/5+345, 230); triangle(-mouseX/5+275, 260, -mouseX/5+310, 210, -mouseX/5+345, 260); //tree trunk back fill(79, 58, 17); rect(-mouseX/20+230, 260, 18, 2000); rect(-mouseX/20+100, 260, 18, 2000); rect(-mouseX/5+300, 260, 18, 2000); //trees front //set fill colour to dark green fill(7, 86, 13); //small trees in the front triangle(-mouseX/10+100, 240, -mouseX/10+120, 210, -mouseX/10+140, 240); triangle(-mouseX/10+100, 260, -mouseX/10+120, 230, -mouseX/10+140, 260); triangle(-mouseX/10+100, 280, -mouseX/10+120, 250, -mouseX/10+140, 280); triangle(-mouseX/10+245, 240, -mouseX/10+265, 210, -mouseX/10+285, 240); triangle(-mouseX/10+245, 260, -mouseX/10+265, 230, -mouseX/10+285, 260); triangle(-mouseX/10+245, 280, -mouseX/10+265, 250, -mouseX/10+285, 280); triangle(-mouseX/3+173, 240, -mouseX/3+193, 210, -mouseX/3+213, 240); triangle(-mouseX/3+173, 260, -mouseX/3+193, 230, -mouseX/3+213, 260); triangle(-mouseX/3+173, 280, -mouseX/3+193, 250, -mouseX/3+213, 280); //Tree trunk for small trees in the front fill(89, 62, 9); rect(-mouseX/10+115, 280, 10, 2000); //I know 2000 is overkill rect(-mouseX/10+260, 280, 10, 2000); rect(-mouseX/3+188, 280, 10, 2000); //floor noStroke(); fill(193, 148, 7); rect(0, 300, 401, 150); //The body of the car fill(175); rect(mouseX-10, 270, 35, 20, 5); rect(mouseX, 258, 120, 30, 5); rect(mouseX+115, 270, 35, 18, 5); quad(mouseX+115, 283, mouseX+115, 258, mouseX+150, 270, mouseX+150, 283); //fill with a transparent black fill(0, 0, 0, 150); stroke(175); strokeWeight(3); //windows for the car quad(mouseX+7, 258, mouseX+40, 244, mouseX+70, 244, mouseX+70, 258); quad(mouseX+70, 244, mouseX+70, 258, mouseX+115, 258, mouseX+80, 244); //Tail lights noStroke(); fill(255, 0, 0); rect(mouseX, 260, 5, 5); rect(mouseX, 267, 5, 5); //Wheels fill(0); ellipse(mouseX+30, 290, 25, 25); ellipse(mouseX+120, 290, 25, 25); //Front Trees fill(7, 86, 13); triangle(-mouseX/.8+373, 280, -mouseX/.8+393, 250, -mouseX/.8+413, 280); triangle(-mouseX/.8+373, 300, -mouseX/.8+393, 270, -mouseX/.8+413, 300); triangle(-mouseX/.8+373, 320, -mouseX/.8+393, 290, -mouseX/.8+413, 320); triangle(-mouseX/.8+273, 280, -mouseX/.8+293, 250, -mouseX/.8+313, 280); triangle(-mouseX/.8+273, 300, -mouseX/.8+293, 270, -mouseX/.8+313, 300); triangle(-mouseX/.8+273, 320, -mouseX/.8+293, 290, -mouseX/.8+313, 320); triangle(-mouseX/.8+123, 320, -mouseX/.8+143, 280, -mouseX/.8+163, 320); triangle(-mouseX/.8+123, 340, -mouseX/.8+143, 310, -mouseX/.8+163, 340); triangle(-mouseX/.8+123, 360, -mouseX/.8+143, 330, -mouseX/.8+163, 360); triangle(-mouseX/.8+423, 320, -mouseX/.8+443, 280, -mouseX/.8+463, 320); triangle(-mouseX/.8+423, 340, -mouseX/.8+443, 310, -mouseX/.8+463, 340); triangle(-mouseX/.8+423, 360, -mouseX/.8+443, 330, -mouseX/.8+463, 360); //Tree trunk fill(89, 62, 9); rect(-mouseX/.8+388, 320, 10, 25); rect(-mouseX/.8+288, 320, 10, 25); rect(-mouseX/.8+138, 360, 10, 25); rect(-mouseX/.8+438, 360, 10, 25); //when you hold click it changes to night, and the headlights shine if (mousePressed) { background(2, 17, 43); //set fill colour to white fill(242, 241, 222); ellipse(350, 50, 30, 30); fill(242, 241, 222, 100); ellipse(350, 50, 40, 40); //set fill colour to pale green fill(24, 94, 29); //Big Trees in the back triangle(-mouseX/20+205, 200, -mouseX/20+240, 150, -mouseX/20+275, 200); triangle(-mouseX/20+205, 230, -mouseX/20+240, 180, -mouseX/20+275, 230); triangle(-mouseX/20+205, 260, -mouseX/20+240, 210, -mouseX/20+275, 260); triangle(-mouseX/20+75, 200, -mouseX/20+110, 150, -mouseX/20+145, 200); triangle(-mouseX/20+75, 230, -mouseX/20+110, 180, -mouseX/20+145, 230); triangle(-mouseX/20+75, 260, -mouseX/20+110, 210, -mouseX/20+145, 260); triangle(-mouseX/5+275, 200, -mouseX/5+310, 150, -mouseX/5+345, 200); triangle(-mouseX/5+275, 230, -mouseX/5+310, 180, -mouseX/5+345, 230); triangle(-mouseX/5+275, 260, -mouseX/5+310, 210, -mouseX/5+345, 260); //tree trunk back fill(79, 58, 17); rect(-mouseX/20+230, 260, 18, 2000); rect(-mouseX/20+100, 260, 18, 2000); rect(-mouseX/5+300, 260, 18, 2000); //set fill colour to dark green fill(7, 86, 13); //small trees in the back triangle(-mouseX/10+100, 240, -mouseX/10+120, 210, -mouseX/10+140, 240); triangle(-mouseX/10+100, 260, -mouseX/10+120, 230, -mouseX/10+140, 260); triangle(-mouseX/10+100, 280, -mouseX/10+120, 250, -mouseX/10+140, 280); triangle(-mouseX/10+245, 240, -mouseX/10+265, 210, -mouseX/10+285, 240); triangle(-mouseX/10+245, 260, -mouseX/10+265, 230, -mouseX/10+285, 260); triangle(-mouseX/10+245, 280, -mouseX/10+265, 250, -mouseX/10+285, 280); triangle(-mouseX/3+173, 240, -mouseX/3+193, 210, -mouseX/3+213, 240); triangle(-mouseX/3+173, 260, -mouseX/3+193, 230, -mouseX/3+213, 260); triangle(-mouseX/3+173, 280, -mouseX/3+193, 250, -mouseX/3+213, 280); //Tree trunk fill(89, 62, 9); rect(-mouseX/10+115, 280, 10, 2000); //I know 2000 is overkill rect(-mouseX/10+260, 280, 10, 2000); rect(-mouseX/3+188, 280, 10, 2000); //floor noStroke(); fill(193, 148, 7); rect(0, 300, 401, 150); //change fill to a transparent yellow fill(255, 255, 0, 75); triangle(mouseX+125, 270, mouseX+1000, 100, mouseX+1000, 400); //The body of the car fill(175); rect(mouseX-10, 270, 35, 20, 5); rect(mouseX, 258, 120, 30, 5); rect(mouseX+115, 270, 35, 18, 5); quad(mouseX+115, 283, mouseX+115, 258, mouseX+150, 270, mouseX+150, 283); //headlight, only appears when you click triangle(mouseX+145, 280, mouseX+125, 280, mouseX+145, 260); //fill with a transparent black fill(0, 0, 0, 150); stroke(175); strokeWeight(3); //windows for the car quad(mouseX+7, 258, mouseX+40, 244, mouseX+70, 244, mouseX+70, 258); quad(mouseX+70, 244, mouseX+70, 258, mouseX+115, 258, mouseX+80, 244); //Tail lights noStroke(); fill(255, 0, 0); rect(mouseX, 260, 5, 5); rect(mouseX, 267, 5, 5); //Wheels fill(0); ellipse(mouseX+30, 290, 25, 25); ellipse(mouseX+120, 290, 25, 25); //set fill colour to fill(7, 86, 13); //Front Trees triangle(-mouseX/.8+373, 280, -mouseX/.8+393, 250, -mouseX/.8+413, 280); triangle(-mouseX/.8+373, 300, -mouseX/.8+393, 270, -mouseX/.8+413, 300); triangle(-mouseX/.8+373, 320, -mouseX/.8+393, 290, -mouseX/.8+413, 320); triangle(-mouseX/.8+273, 280, -mouseX/.8+293, 250, -mouseX/.8+313, 280); triangle(-mouseX/.8+273, 300, -mouseX/.8+293, 270, -mouseX/.8+313, 300); triangle(-mouseX/.8+273, 320, -mouseX/.8+293, 290, -mouseX/.8+313, 320); triangle(-mouseX/.8+123, 320, -mouseX/.8+143, 280, -mouseX/.8+163, 320); triangle(-mouseX/.8+123, 340, -mouseX/.8+143, 310, -mouseX/.8+163, 340); triangle(-mouseX/.8+123, 360, -mouseX/.8+143, 330, -mouseX/.8+163, 360); triangle(-mouseX/.8+423, 320, -mouseX/.8+443, 280, -mouseX/.8+463, 320); triangle(-mouseX/.8+423, 340, -mouseX/.8+443, 310, -mouseX/.8+463, 340); triangle(-mouseX/.8+423, 360, -mouseX/.8+443, 330, -mouseX/.8+463, 360); //Tree trunk fill(89, 62, 9); rect(-mouseX/.8+388, 320, 10, 25); rect(-mouseX/.8+288, 320, 10, 25); rect(-mouseX/.8+138, 360, 10, 25); rect(-mouseX/.8+438, 360, 10, 25); } }