Your browser does not support the canvas tag.

previous        Show / Hide Source        Download        next
void setup()
{

/*

Shovel Knight's Respite
Made by: Andre Bernardo

-> Move your mouse left to right to have Shovel Knight "catch some Z's" and regain his stamina
-> Move your mouse up to down to have Shovel Knight slump forward
-> Click to make him sleep talk... what is he dreaming about?

*/

  //Creates a window 400 by 400 pixels.
size(400,400);


  //Removes the cursor.
noCursor();

}

void draw()
{  
  // Sets frame rate to 60 frames per second.
  frameRate(60);
  
background(0);
  
  // Doesn't generate outlines for shapes.
noStroke();

// ********* STAMINA BAR ************

//holder
fill(200);
rect(200,35,350,40,20);

//bar
fill(233,187,23);
rectMode(CORNER);
rect(30,20,0+mouseX/1.17,30,20);

//bar shine
fill(245,225,154);
rectMode(CORNER);
rect(36,23,0+mouseX/1.21,8,20);

rectMode(CENTER);

// ********* SHADOWS *********
/*
Creates shadows and cast shadows, assuming there is an inconsistent
light source in front of Shovel Knight. The inconsistency of the size of shadows
is done automatically using a sine function and 'frameCount' so that they aren't
shrinking and enlarging at an unrealistic speed.

Using the sine function is based from P.Y. Boulerice's interactive drawing from the
PROG14998 Interactive Drawing Gallery of 2015
*/
  

  
//shadow 4
fill(80);
ellipse(200,340,700 + (sin(frameCount * 0.15) * 10.),300 + (sin(frameCount * 0.15) * 10.));

//shadow 3
fill(100);
ellipse(200,390,650 + (sin(frameCount * 0.15) * 10.),300 + (sin(frameCount * 0.15) * 10.));

//shadow 2
fill(120);
ellipse(200,430,600 + (sin(frameCount * 0.15) * 10.),300 + (sin(frameCount * 0.15) * 10.));
  
//shadow 1
fill(190);
ellipse(200,450,500 + (sin(frameCount * 0.15) * 10.),300 + (sin(frameCount * 0.15) * 10.));
  
//********* SHOVEL KNIGHT *********
  
/* 
  Shovel Knight's shoulders and head slump relative to the mouse X position. His
  helmet visor slowly shrinks as well, giving the cartoon feel that he is going to 
  sleep although they aren't his "real" eyes.
  
  Shoulder plate shine works similarly to the cast shadows utilizing the sine function 
  'frameCount'.
*/
  
//BODY
 
fill(56,192,252);
ellipse(200,400,120,160);
  
//SHOULDERS
  
//left shoulder trim
fill(253,176,100);
ellipse(105,372+mouseY/40,115,65);
  
//left shoulder
fill(56,192,252);
ellipse(105,360+mouseY/40,100,70);
  
//left shoulder shine
fill(160,226,254);
ellipse(105,380+mouseY/40,50 + (sin(frameCount * 0.15) * 2.),20 + (sin(frameCount * 0.15) * 2.));
  
//right shoulder trim
fill(253,176,100);
ellipse(295,372+mouseY/40,115,65);
  
//right shoulder
fill(56,192,252);
ellipse(295,360+mouseY/40,100,70);
  
//right shoulder shine
fill(160,226,254);
ellipse(295,380+mouseY/40,50 + (sin(frameCount * 0.15) * 2.),20 + (sin(frameCount * 0.15) * 2.));
  
//HELMET
  
//helmet base
fill(56,192,252);
rect(200,300+mouseY/20,100,100,20);

//helmet shadow
fill(3,137,194);
rect(200,260+mouseY/20,90,20,20);

//helmet shine
fill(160,226,254);
rect(200,342+mouseY/20,100,18,5);

//helmet gap mouth
rectMode(CENTER);
fill(0);
rect(200,325+mouseY/20,18,52);

//helmet gap eyes
fill(0);
rect(200,295+mouseY/20,75,18-mouseY/40,8);

//left horn base
fill(253,201,149);
triangle(150,285+mouseY/20,100,230+mouseY/20,163,250+mouseY/20);

//left horn mid
fill(253,176,100);
triangle(135,190+mouseY/20,100,230+mouseY/20,140,245+mouseY/20);

//left horn tip
fill(252,160,72);
triangle(135,220+mouseY/20,170,180+mouseY/20,135,190+mouseY/20);

//right horn base
fill(253,201,149);
triangle(250,285+mouseY/20,300,230+mouseY/20,237,250+mouseY/20);

//right horn mid
fill(253,176,100);
triangle(265,190+mouseY/20,300,230+mouseY/20,260,245+mouseY/20);

//right horn tip
fill(252,160,72);
triangle(265,220+mouseY/20,230,180+mouseY/20,265,190+mouseY/20);

// ********* SNORES *********

/*

Shovel Knight snores relative to mouse X. This is done by having the opacity of 
the "Z"s increase and decrease relative to mouse X.

*/
fill(255,255,255,mouseX/1.5);
rect(330,100,30,10);
rect(340,110,10,10);
rect(330,120,10,10);
rect(320,130,10,10);
rect(330,140,30,10);

fill(255,255,255,mouseX/1.5);
rect(290,160,30,10);
rect(300,170,10,10);
rect(290,180,10,10);
rect(280,190,10,10);
rect(290,200,30,10);

}

/*

When clicking the mouse, Shovel Knight will mutter something in the console.

*/

void mousePressed()
{
  print("Shield Knight... ");
 
}