Your browser does not support the canvas tag.

previous        Show / Hide Source        Download        next
/*
Designer: Mosang Liu
Instructor: Nicolas Hesler
Sept 13,2018
*/

void setup() {
//Set window size
  size(400, 400);
  
  smooth();

//Discard corsor
  noCursor();
  
}


void draw(){
//Setup frameRate
  frameRate(120);
  
//Set rect mode
  rectMode(CORNERS);
  
//Set ellipse mode
  ellipseMode(CENTER);  
  
//Discard stroke 
  noStroke();

//Set background
  background(100);
  
//Desk gradual change
  fill(130);
  rect(0,300,400,320);
  fill(140);
  rect(0,320,400,340);
  fill(150);
  rect(0,340,400,360);
  fill(160);
  rect(0,360,400,380);
  fill(170);
  rect(0,380,400,400);

//Screen bracket
  fill(50);
  triangle(200,280,100,380,300,380);
  fill(55);
  rect(100,380,300,400);
  fill(80,79,75);
  rect(140,300,260,360);
  fill(130);
  ellipse(200,300,80,80);

//Display screen
  fill(110,136,249);
  rect(10,10,390,290);
  
//Controller
  stroke(0);
  strokeWeight(2);
  line(110,300,50,330);
  noStroke();
  fill(90,37,43);
  rect(0,330,100,380,12,12,12,12);
  fill(26);
  rect(20,340,30,370,3,3,3,3);
  rect(10,350,40,360,3,3,3,3);
  fill(53,20,178);
  ellipse(60,350,20,20);
  fill(145,5,28,(sin((mouseX+mouseY)*.01*HALF_PI)*255));
  ellipse(60,350,20,20);
  fill(145,5,28);
  ellipse(80,360,20,20);
  fill(53,20,178,(sin((mouseX+mouseY)*.01*HALF_PI)*255));
  ellipse(80,360,20,20);
  
//Moving mouse
  strokeWeight(1);
  fill(90,37,43);
  ellipse(320+mouseX*.15,330+mouseY*.1,40,60);
  stroke(255);
  line(300+mouseX*.15,330+mouseY*.1,340+mouseX*.15,330+mouseY*.1);
  line(320+mouseX*.15,300+mouseY*.1,320+mouseX*.15,330+mouseY*.1);
  strokeWeight(2);
  stroke(0);
  line(260,300,320+mouseX*.15,300+mouseY*.1);  
/*
In the beginning, 
these lines and shapes are begin and end at intersections on the graph paper.
Yet, they are exceed the blocks and the pipe.
So I made a little adjustment to make it looks not that weird.
*/  
//Blocks
  noStroke();
  fill(219,79,17);
  rect(30,110,70,150);
  rect(110,110,150,150);
  rect(190,110,230,150);
  stroke(0);
  line(30,120,229,120);
  line(30,130,229,130);
  line(30,140,229,140);
  
  line(50,110,50,120);
  line(40,120,40,130);
  line(60,120,60,130);
  line(50,130,50,140);
  line(40,140,40,149);
  line(60,140,60,149);
  
  line(130,110,130,120);
  line(120,120,120,130);
  line(140,120,140,130);
  line(130,130,130,140);
  line(120,140,120,149);
  line(140,140,140,149);
  
  line(210,110,210,120);
  line(200,120,200,130);
  line(220,120,220,130);
  line(210,130,210,140);
  line(200,140,200,149);
  line(220,140,220,149);
  
//Item blocks
  stroke(0);
  strokeWeight(1);
  fill(168,82,4);
  rect(70,110,110,150);
  fill(223,157,37);
  rect(150,110,190,150);
  strokeWeight(4);
  point(75,115);
  point(105,115);
  point(75,145);
  point(105,145);
  point(155,115);
  point(185,115);
  point(185,145);
  point(155,145);
  
//question mark
  stroke(172,86,7);
  line(164,119,164,128);
  line(166,118,174,118);
  line(176,119,176,128);
  line(176,128,170,133);
  line(170,133,170,138);
  point(170,143);
  
//Pipe
  stroke(0);
  strokeWeight(2);
  fill(145,236,8);
  rect(290,200,388,240);
  rect(298,240,380,289);

//Pipe hightligth+shadow
  noStroke();
  fill(26,171,4);
  rect(292,205,310,210);
  rect(330,205,387,210);
  rect(300,210,310,239);
  rect(330,210,335,239);
  rect(340,210,360,239);
  rect(310,242,320,288);
  rect(335,242,340,288);
  rect(350,242,360,288);

  rect(370,210,380,220);
  rect(360,220,370,230);
  rect(370,230,380,239);
  rect(360,242,370,250);
  rect(360,260,370,270);
  rect(360,280,370,288);
  rect(370,250,379,260);
  rect(370,270,379,280);

//Moving mushroom
  fill(222,157,41);
  ellipse(130+sin(frameCount*.01)*90,70,16,19);
  ellipse(110+sin(frameCount*.01)*90,90,19,18);
  ellipse(150+sin(frameCount*.01)*90,90,19,18);
  triangle(130+sin(frameCount*.01)*90,60,100+sin(frameCount*.01)*90,90,160+sin(frameCount*.01)*90,90);
  rect(110+sin(frameCount*.01)*90,80,150+sin(frameCount*.01)*90,100);
  fill(255);
  rect(120+sin(frameCount*.01)*90,100,140+sin(frameCount*.01)*90,110,0,0,6,6);
  fill(170,30,27);
  rect(110+sin(frameCount*.01)*90,90,120+sin(frameCount*.01)*90,100);
  rect(140+sin(frameCount*.01)*90,90,150+sin(frameCount*.01)*90,100);
  rect(120+sin(frameCount*.01)*90,75,130+sin(frameCount*.01)*90,85);
  triangle(140+sin(frameCount*.01)*90,70,140+sin(frameCount*.01)*90,80,150+sin(frameCount*.01)*90,80);

//Cloud
/*
  I create queued clouds for a continuing movement.
  However,I can't make a streaming circle with allowed statements.
  It can run for a while but will stop after clouds are depleted.
*/
  rectMode(CENTER);
  fill(230);
  ellipse(frameCount*.3-20,30,40,20);
  ellipse(frameCount*.3-0,40,20,20);
  ellipse(frameCount*.3-40,40,20,20);
  rect(frameCount*.3-20,40,40,20);
  
  ellipse(frameCount*.3-420,30,40,20);
  ellipse(frameCount*.3-400,40,20,20);
  ellipse(frameCount*.3-440,40,20,20);
  rect(frameCount*.3-420,40,40,20);
  
  ellipse(frameCount*.3-820,30,40,20);
  ellipse(frameCount*.3-800,40,20,20);
  ellipse(frameCount*.3-840,40,20,20);
  rect(frameCount*.3-820,40,40,20);
  
  ellipse(frameCount*.3-1220,30,40,20);
  ellipse(frameCount*.3-1200,40,20,20);
  ellipse(frameCount*.3-1240,40,20,20);
  rect(frameCount*.3-1220,40,40,20);
  
  ellipse(frameCount*.3-1620,30,40,20);
  ellipse(frameCount*.3-1600,40,20,20);
  ellipse(frameCount*.3-1640,40,20,20);
  rect(frameCount*.3-1620,40,40,20);
  
  ellipse(frameCount*.3-2020,30,40,20);
  ellipse(frameCount*.3-2000,40,20,20);
  ellipse(frameCount*.3-2040,40,20,20);
  rect(frameCount*.3-2020,40,40,20);
  
//Mario
/*I'm so sorry I cheated. 
  I used a out sourse picture as a reference to make my Mario looks perfect, 
  because the one that I designed is a faulty part,
  I can't make a Mario witch can quite compare to the original one.
*/
  rectMode(CORNERS);

  //Yellow parts
  fill(255,163,71);
  rect(70,225,75,235);
  rect(75,220,110,245);
  rect(105,225,115,235);
  rect(115,230,120,235);
  rect(105,240,110,245);
  rect(60,260,70,275);
  rect(70,265,75,270);
  rect(105,265,110,270);
  rect(110,260,120,275);
  //Green parts
  fill(175,127,0);
  rect(70,220,85,225);
  rect(95,220,100,230);
  rect(65,225,70,240);
  rect(70,235,75,240);
  rect(75,225,80,235);
  rect(80,230,85,235);
  rect(100,230,105,235);
  rect(95,235,115,240);
  rect(70,245,110,250);
  rect(65,250,115,255);
  rect(60,255,120,260);
  rect(70,260,110,265);
  rect(65,280,80,290);
  rect(60,285,65,290);
  rect(100,280,115,290);
  rect(115,285,120,290);
  //Red parts
  fill(248,56,0);
  rect(75,210,100,215);
  rect(70,215,115,220);
  rect(80,245,85,255);
  rect(80,255,95,260);
  rect(95,245,100,260);
  rect(75,260,105,275);
  rect(70,270,85,280);
  rect(95,270,110,280);
  //Buttens
  fill(255,163,71);
  rect(80,260,85,265);
  rect(95,260,100,265);

//Screen frame
  fill(70,69,65);
  rect(0,0,10,300);
  rect(10,0,400,10);
  rect(390,10,400,290);
  rect(10,290,400,300);

}

//Let Mario Jump by mouseClicked()
//Hide standing Mario and make a Jumping Mario
void mouseClicked(){

//Reduce frameRate, adjust time of duration.
  frameRate(1.5);
  
//Hide Mario
  fill(110,136,249);
  rect(60,210,120,290);
  
//Hide mushroom
  fill(110,136,249);
  rect(10,60,250,110);

//Jumping Mario
  //Yellow parts
  fill(255,163,71);
  rect(115,150,130,165);
  rect(80,165,110,190);
  rect(75,170,80,180);
  rect(110,170,120,175);
  rect(110,175,125,180);
  rect(110,185,115,190);
  rect(50,200,65,210);
  rect(55,210,60,215);
  //Green parts
  fill(175,127,0); 
  rect(75,165,90,170);
  rect(100,165,105,175);
  rect(115,165,130,180);
  rect(70,170,75,185);
  rect(75,180,80,185);
  rect(80,170,85,180);
  rect(85,175,90,180);
  rect(105,175,110,180);
  rect(100,180,125,185);
  rect(115,185,120,190);
  rect(55,195,60,200);
  rect(60,190,115,205);
  rect(125,200,130,205);
  rect(120,205,130,220);
  rect(65,210,70,215);
  rect(60,215,75,220);
  rect(55,220,70,225);
  rect(55,225,60,230);
  //Red parts
  fill(248,56,0);
  rect(80,155,100,160);
  rect(75,160,120,165);
  rect(85,190,90,195);
  rect(105,190,110,195);
  rect(90,195,95,200);
  rect(110,195,115,200);
  rect(90,200,115,205);
  rect(75,205,120,220);
  rect(70,220,105,205);
  rect(70,205,90,230);
  //Nose+Button
  fill(255,163,71);
  rect(110,170,120,175);
  rect(110,175,125,180);
  rect(100,205,105,210);
  rect(110,205,115,210);
  //Green pixel
  fill(175,127,0); 
  rect(80,205,85,210);
  
  //Mushroom
  fill(222,157,41);
  ellipse(90,70,16,19);
  ellipse(70,90,19,18);
  ellipse(110,90,19,18);
  triangle(90,60,60,90,120,90);
  rect(70,80,110,100);
  fill(255);
  rect(80,100,100,110,0,0,6,6);
  fill(170,30,27);
  rect(70,90,80,100);
  rect(100,90,110,100);
  rect(80,75,90,85);
  triangle(100,70,100,80,110,80);

}