Your browser does not support the canvas tag.

previous        Show / Hide Source        Download        next
// Navi in Temple of Time by Benjamin d'Abadie




//Move Navi around the Temple of Time with the mouse
//Move mouse up and down to open the door to the sword chamber
//When door is opened click mouse to see what is inside the chamber




void setup() { 
  
  
 

// Creats a window 400 pixels by 400 pixels
size(400, 400);




// Remove cursor
noCursor();




// Navi is tries to get your attention
println ("Hey! Listen!");
}




void draw() {
smooth();




// 60 FPS for the win!
frameRate(60);




// Set Background color
background(123,130,123);




// Set rect mode to CORNERS
rectMode(CORNERS);




// Set ellipse mode to CENTER
ellipseMode(CENTER);




// Draw walls and big pillars
fill(110, 122, 110);
stroke(121, 135, 121);
strokeWeight(1);
quad(20, 0, 20, 190, 40, 200, 40, 0);
quad(60, 0, 60, 200, 80, 190, 80, 0);
quad(320, 0, 320, 190, 340, 200, 340, 0);
quad(360, 0, 360, 200, 380, 190, 380 ,0);
fill(119, 133, 119);
stroke(105, 117, 105);
rect(40, 0, 60, 200);
rect(340, 0, 360, 200);
fill(135, 150, 135);
stroke(110,122,110);
rect(80, 0, 100, 190);
rect(300, 0, 320, 190);
rect(0, 0, 20, 190);
rect(380, 0, 400, 190);
fill(121, 135, 121);
quad(100, 0, 100, 190, 120, 160, 120, 0);
quad(280, 0, 280, 160, 300, 190, 300, 0);




// Draw Door
fill(160);
stroke(70);
strokeWeight(3);
rect(140, 70, 260, 160);
stroke(100);
strokeWeight(1);
rect(150, 80, 250, 160);
fill(200);
ellipse(200, 100, 20, 20);
line(150, 100, 180, 100);
line(150, 140, 180, 110);
line(170, 150, 180, 130);
line(190, 160, 190, 130);
line(210, 160, 210, 130);
line(220, 130, 230, 150);
line(220, 110, 250, 140);
line(220, 100, 250, 100);




// Make Door Open and Close. Black rectangle covers the door when cursor is moved towards the top of the screen, and receeds as the mouse is move away from the top.
// This took some trial and error to get right.
fill(0);
rect(140, -70+(mouseY), 260, 160+(mouseY));




// Draw Pathway to door
fill(225);
stroke(180);
strokeWeight(2);
quad(80, 400,140, 160, 260, 160, 340, 400);




// Draw left side of pathway tiles
line(135, 180, 150, 180);
line(130, 200, 145, 200);
line(125, 220, 140, 220);
line(120, 240, 135, 240);
line(115, 260, 130, 260);
line(110, 280, 125, 280);
line(105, 300, 120, 300);
line(100, 320, 115, 320);
line(95, 340, 115, 340);
line(90, 360, 110, 360);
line (85, 380, 115, 380);




// Draw right side of pathway tiles
line(250, 180, 265, 180);
line(255, 200, 273, 200);
line(260, 220, 280, 220);
line(265, 240, 285, 240);
line(270, 260, 293, 260);
line(275, 280, 298, 280);
line(280, 300, 306, 300);
line(285, 320, 312, 320);
line(290, 340, 318, 340);
line(295, 360, 325, 360);
line(300, 380, 332, 380);




// Draw tiles on temple ground
stroke(100);
line(100, 190, 130, 190);
line(0, 230, 120, 230);
line(0, 290, 105, 290);
line(0, 350, 90, 350);
line(273, 190, 300, 190);
line(287, 230, 400, 230);
line(306, 290, 400, 290);
line(327, 350, 400, 350);





// Draw Carpet on pathway
stroke(242, 211, 16);
strokeWeight(1);
fill(196,0,0);
quad(100, 400, 150, 160, 250, 160, 320, 400);




// Draw Wall behind Tri-force
noStroke();
fill(123, 130, 123);
rect(140, 0, 260, 70);




// Draw Tri-Force
stroke(193, 173, 13);
strokeWeight(1);




// Tri-Force changes colour from dark gold almost black to bright yellow gold depending on position of mouse on the y axis i.e where Navi is relation to the Tri-Force
fill(-mouseY/2+242,-mouseY/2+211,-mouseY/2+16);
triangle(160, 60, 180, 30, 200, 60);
triangle(200, 60, 220, 30, 240, 60);
triangle(180, 30, 200, 0, 220, 30);
fill(240);
triangle(180, 30, 200, 60, 220, 30);




// Draw Pillars around door
fill(185);
stroke(125);
strokeWeight(1);
rect(120, 0, 140, 160);
rect(260, 0, 280, 160);
line(120, 120, 140, 120);
line(120, 80, 140, 80);
line(120, 40, 140, 40);
line(260, 40, 280, 40);
line(260, 80, 280, 80);
line(260, 120, 280, 120);



// Navi will follow the cursor wherever it goes, so she will follow you wherever you go :)

// Draw Navi's Wings
stroke(123, 246, 255, 100);
strokeWeight(2);
fill(196, 255, 209, 100);
triangle(mouseX, mouseY, pmouseX+80, pmouseY-60, pmouseX+65, pmouseY+10);
triangle(mouseX, mouseY, pmouseX-80, pmouseY-60, pmouseX-65, pmouseY+10);
triangle(mouseX, mouseY, pmouseX+20, pmouseY+50, pmouseX+50, pmouseY+60);
triangle(mouseX, mouseY, pmouseX-20, pmouseY+50, pmouseX-50, pmouseY+60);




// Draw Navi's Body
stroke(60, 193, 241, 80);
strokeWeight(5);
fill(60, 193, 241, 200);
ellipse(mouseX, mouseY, 90,90);
noStroke();
fill(165, 224, 224, 250);
ellipse(mouseX, mouseY, 60,60);

}




// Sword in pedestal appears with mouse click
void mousePressed(){
frameRate(5);
stroke(160);
strokeWeight(1);
fill(190);
quad(160, 140, 180, 120, 220, 120, 240, 140);
fill(255);
rect(195, 110, 205, 120);
fill(98, 9, 186);
quad(185, 110, 195, 105, 205, 105, 215, 110); 
rect(198, 90, 202, 105);




//Navi brings your attention to the master sword
println ("Look!"); 

}