//INTERACTIVE DRAWING
//"DARK SUN" BY KEVAN CHAMBERS
//MOVE MOUSE LEFT AND RIGHT TO SHIFT HORIZON (SUN, DUNES, PYRAMIDS) & COLOUR ORB
//MOVE MOUSE UP AND DOWN TO OPEN AND CLOSE THE PYRAMID
//CLICK MOUSE TO FIRE A BEAM FROM THE PYRAMID'S EYE & DISPLAY A MESSAGE IN CONSOLE
//PRESS ANY KEY TO DISPLAY A MESSAGE IN CONSOLE
void setup() {
//Determines canvas size
size(400, 400);
}
void draw() {
//Caps framerate at 60 frames per second
frameRate(60);
///////////////////////////////////SKY///////////////////////////////////
//Changes background colour to grey-red to simulate surreal sky
background(200, 150, 150);
noStroke();
//Draws/colours corona 1 (the lightest)
fill(210, 150, 150);
ellipse((mouseX+7500)/100, 125, 300, 300);
//Draws/colours corona 2 (the second lightest)
fill(210, 140, 140);
ellipse((mouseX+7500)/100, 125, 250, 250);
//Draws/colours corona 3 (the third lightest)
fill(210, 130, 130);
ellipse((mouseX+7500)/100, 125, 200, 200);
//Draws/colours corona 4 (the second darkest)
fill(210, 120, 120);
ellipse((mouseX+7500)/100, 125, 150, 150);
//Draws/colours corona 5 (the darkest)
fill(210, 110, 110);
ellipse((mouseX+7500)/100, 125, 100, 100);
//Draws/colours the "dark sun" a dark red
fill(150, 0, 0);
ellipse((mouseX+7500)/100, 125, 50, 50);
//Draws clouds and colours them a semi-transparent grey-black
fill(25, 150);
rect(240-frameCount/3, 120, 120, 40, 10);
rect(300-frameCount/5, 100, 120, 40, 10);
///Clouds travel slowly across the screen right-to-left
///////////////////////////////////BACKGROUND///////////////////////////////////
//Draws background dune and colours it palest yellow
fill(255, 255, 150);
ellipse(mouseX/10, 350, 300, 200);
//Draws background pyramid sun-facing side and colours it light grey
fill(100);
triangle((mouseX+50)/10, 260, mouseX/10, 235, (mouseX+150)/10, 253);
//Draws background pyramid shadowed side and colours it grey
fill(75);
triangle((mouseX-150)/10, 255, mouseX/10, 235, (mouseX+60)/10, 260);
///////////////////////////////////MIDGROUND///////////////////////////////////
//Draws midground dune and colours it pale yellow
fill(255, 255, 50);
ellipse((mouseX+1625)/5, 350, 300, 150);
//Draws midground pyramid sun-facing side and colours it grey
fill(75);
triangle((mouseX+1350)/5, 280, (mouseX+1500)/5, 240, (mouseX+1555)/5, 290);
//Draws midground pyramid shadowed side and colours it dark grey
fill(50);
triangle((mouseX+1550)/5, 290, (mouseX+1500)/5, 240, (mouseX+1650)/5, 280);
///////////////////////////////////FOREGROUND///////////////////////////////////
//Draws foreground dune and colours it yellow
fill(200, 200, 0);
ellipse(200, 400, 550, 150);
//Draws foreground pyramid interior and colours it grey-black
fill(25);
quad(125, 280, 175, 265, 225, 265, 275, 280);
//Draws foreground pyramid base and colours it dark grey
fill(50);
quad(75, 350, 125, 280, 275, 280, 325, 350);
//Draws pyramid orb and colours it based on the mouse's x position
fill(255-mouseX, 0, 0);
ellipse(200, (mouseY+2200)/10, 30, 30);
//Draws pyramid orb eye and colours it based on the mouse's x position
fill(mouseX, 0, 0);
ellipse(200, (mouseY+2200)/10, 5, 15);
//Draws foreground pyramid top and colours it dark grey
fill(50);
triangle(125, (mouseY+445)/3, 200, (mouseY+150)/3, 275, (mouseY+445)/3);
}
void mousePressed() {
//Lowers framerate on mouseclick so laser effect lasts 1/12th of a second
frameRate(5);
//Changes laser colour to match colour of orb's eye
stroke(mouseX, 0, 0);
fill(mouseX, 0, 0);
//Fires a laser on mouseclick from center of orb's eye to mouse location
strokeWeight(5);
line(200, (mouseY+2200)/10, mouseX, mouseY);
//Draws laser explosion effect on mouseclick at mouse location
triangle(mouseX-5, mouseY-5, mouseX, mouseY+20, mouseX+5, mouseY-5);
triangle(mouseX-5, mouseY+5, mouseX, mouseY-20, mouseX+5, mouseY+5);
//Draws screen cracking effect on mouseclick at mouse location
stroke(255);
strokeWeight(1);
line(mouseX, mouseY, mouseX-30, mouseY-30);
line(mouseX-30, mouseY-30, mouseX-40, mouseY-60);
line(mouseX-32, mouseY-35, mouseX-55, mouseY-40);
line(mouseX, mouseY, mouseX+25, mouseY+10);
line(mouseX+25, mouseY+10, mouseX+35, mouseY-45);
line(mouseX+28, mouseY-10, mouseX+5, mouseY-25);
line(mouseX+5, mouseY-25, mouseX-15, mouseY-15);
line(mouseX, mouseY, mouseX-5, mouseY+50);
line(mouseX-3, mouseY+30, mouseX-35, mouseY+25);
line(mouseX-35, mouseY+25, mouseX-40, mouseY+35);
line(mouseX-7, mouseY-7, mouseX-30, mouseY+10);
line(mouseX-30, mouseY+10, mouseX-35, mouseY+25);
line(mouseX+15, mouseY+7, mouseX+60, mouseY+85);
//Displays a message in console when mouse is clicked
println("You can't keep me in here forever.");
}
void keyPressed() {
//Displays a message in console when any key is pressed
println("Here, the sun shines darkly.");
}