Your browser does not support the canvas tag.

previous        Show / Hide Source        Download        next
/***********************
Sebastian Santmaura's
Sentient Training Dummy
"Pracice your swordsmanship!"
September 22th, 2016
*************************/
//Setup
void setup(){
//size
 size(400,400);
}

void draw(){
 //background wall
 background(70,70,70);
 //framerate
 frameRate(60);
 noStroke();
 rectMode(CORNERS);
 //green grass ground
 fill(0,175,10);
 rect(0,350,400,400);
 
 //gray bricks for wall
   rectMode(CENTER);
   fill(130,130,130);
   rect(35,25,60,40);
   rect(105,25,60,40);
   rect(175,25,60,40);
   rect(245,25,60,40);
   rect(315,25,60,40);
   rect(385,25,60,40);
 
   rect(0,75,60,40);
   rect(70,75,60,40);
   rect(140,75,60,40);
   rect(210,75,60,40);
   rect(280,75,60,40);
   rect(350,75,60,40);
   rect(420,75,60,40);
 
   rect(35,125,60,40);
   rect(105,125,60,40);
   rect(175,125,60,40);
   rect(245,125,60,40);
   rect(315,125,60,40);
   rect(385,125,60,40);
 
   rect(0,175,60,40);
   rect(70,175,60,40);
   rect(140,175,60,40);
   rect(210,175,60,40);
   rect(280,175,60,40);
   rect(350,175,60,40);
   rect(420,175,60,40);
 
   rect(35,225,60,40);
   rect(105,225,60,40);
   rect(175,225,60,40);
   rect(245,225,60,40);
   rect(315,225,60,40);
   rect(385,225,60,40);
 //SO MANY!!!
   rect(0,275,60,40);
   rect(70,275,60,40);
   rect(140,275,60,40);
   rect(210,275,60,40);
   rect(280,275,60,40);
   rect(350,275,60,40);
   rect(420,275,60,40);
  
   rect(35,325,60,40);
   rect(105,325,60,40);
   rect(175,325,60,40);
   rect(245,325,60,40);
   rect(315,325,60,40);
   rect(385,325,60,40);
 //the making of the dummy was more
 //time consuming than the wall
 //wooden stand
 rectMode(CORNERS);
 fill(98,66,18);
 rect(180,280,220,350);
 //wooden "arms"
 rect(60,120,80,130);
 rect(320,120,340,130);
 //wooden "neck"
 rect(190,80,210,120);
 
 stroke(0);
 //chainmail shirt
 fill(190,190,190);
 rect(80,118,320,150);
 rect(155,118,245,280);

 ellipseMode(CORNERS);
 //metal helmet
 ellipse(165,35,235,105);
 noStroke();
 
 ellipseMode(CENTER);
 //wooden head
 fill(150,110,50);
 arc(200, 70, 70, 70,0, PI);
 //helmet details
 fill(190,190,190);
 rect(195,70,205,90);
 //more deets
 fill(100,100,100);
 rect(165,63,235,70);
 //bolts in helmet
 fill(120,120,120);
 ellipse(170,66.5,3,3);
 ellipse(180,66.5,3,3);
 ellipse(190,66.5,3,3);
 ellipse(200,66.5,3,3);
 ellipse(210,66.5,3,3);
 ellipse(220,66.5,3,3);
 ellipse(230,66.5,3,3);
 //shine
 fill(255);
 ellipse(210,50,10,10);
 
 //blades of grass
 fill(0,175,10);
 triangle(350,340,360,350,355,350);
 triangle(360,350,370,350,370,320);
 triangle(365,350,370,350,380,330);
 triangle(370,350,375,350,390,330);
 
 //wooden details
 stroke(70,40,0);
 noFill();
 strokeWeight(2);
 line(215,300,215,345);
 line(205,282,205,320);
 line(200,300,200,335);
 line(190,290,190,325);
 line(190,330,190,346);
 line(185,282,185,310);
 
 line(195,107,195,110);
line(200,111,200,116);
line(205,108,205,114);

line(338,122,330,122);
line(322,126,332,126);

line(61,122,73,122);
line(61,126,69,126);

//chainmail details(cross hatches)
stroke(95,95,95);
line(80,120,100,150);
line(100,120,120,150);
line(120,120,140,150);
line(140,120,245,275);
line(155,173,226,280);
line(155,202,205,280);
line(155,235,185,280);
line(160,120,245,247);
line(180,120,245,215);
line(200,120,245,185);
line(220,120,245,155);
line(240,120,260,150);
line(260,120,280,150);
line(280,120,300,150);
line(300,120,320,150);

line(320,120,300,150);
line(300,120,280,150);
line(280,120,260,150);
line(260,120,156,276);
line(240,120,156,244);
line(220,120,154,218);
line(200,120,154,188);
line(180,120,155,154);
line(160,120,140,150);
line(140,120,120,150);
line(120,120,100,150);
line(100,120,80,150);
line(244,178,175,280);
line(244,207,195,280);
line(244,235,215,280);

//more grass blades
fill(0,175,10);
noStroke();
triangle(230,330,220,350,215,350);
triangle(230,320,215,350,205,350);
triangle(210,320,205,350,195,350);
triangle(212,330,210,350,205,350);
triangle(190,330,210,350,205,350);
triangle(195,350,190,350,180,320);
triangle(190,350,180,350,170,330);
triangle(170,330,168,335,172,332);
triangle(180,350,160,340,190,350);

//scleras(eyes)
fill(255);
ellipse(184,80,18,18);
ellipse(216,80,18,18);
//pupils follow the mouse
noStroke();
ellipseMode(CORNERS);
fill(0);
ellipse(205.7+mouseX/40,70+mouseY/40,215.7+mouseX/40,80+mouseY/40);
ellipse(175.7+mouseX/40,70+mouseY/40,185.7+mouseX/40,80+mouseY/40);
//wooden sword that is always on the mouse's position
fill(77,46,4);
rectMode(CENTER);
rect(mouseX,mouseY,10,30);
rect(mouseX,mouseY-15,50,10);
rect(mouseX,mouseY-60,30,80);
triangle(mouseX-15,mouseY-100,mouseX,mouseY-120,mouseX+15,mouseY-100);
stroke(70,40,0);
line(mouseX,mouseY-25,mouseX,mouseY-105);

}
/*sword tilts when the mouse is pressed, 
giving the impression of being swung.
The dummy also closes its eyes*/
void mousePressed(){
 //had to remake the entire wall + dummy to hide the upward sword :/
   background(70,70,70);
   //so you can see the changes easier
 frameRate(5);
 noStroke();
 rectMode(CORNERS);
 //ground
 fill(0,175,10);
 rect(0,350,400,400);
 //bricks
   rectMode(CENTER);
   fill(130,130,130);
   rect(35,25,60,40);
   rect(105,25,60,40);
   rect(175,25,60,40);
   rect(245,25,60,40);
   rect(315,25,60,40);
   rect(385,25,60,40);
 
   rect(0,75,60,40);
   rect(70,75,60,40);
   rect(140,75,60,40);
   rect(210,75,60,40);
   rect(280,75,60,40);
   rect(350,75,60,40);
   rect(420,75,60,40);
 
   rect(35,125,60,40);
   rect(105,125,60,40);
   rect(175,125,60,40);
   rect(245,125,60,40);
   rect(315,125,60,40);
   rect(385,125,60,40);
 
   rect(0,175,60,40);
   rect(70,175,60,40);
   rect(140,175,60,40);
   rect(210,175,60,40);
   rect(280,175,60,40);
   rect(350,175,60,40);
   rect(420,175,60,40);
 //this is what happens without loops
   rect(35,225,60,40);
   rect(105,225,60,40);
   rect(175,225,60,40);
   rect(245,225,60,40);
   rect(315,225,60,40);
   rect(385,225,60,40);
 
   rect(0,275,60,40);
   rect(70,275,60,40);
   rect(140,275,60,40);
   rect(210,275,60,40);
   rect(280,275,60,40);
   rect(350,275,60,40);
   rect(420,275,60,40);
  
   rect(35,325,60,40);
   rect(105,325,60,40);
   rect(175,325,60,40);
   rect(245,325,60,40);
   rect(315,325,60,40);
   rect(385,325,60,40);
 
 rectMode(CORNERS);
 fill(98,66,18);
 rect(180,280,220,350);
 
 rect(60,120,80,130);
 rect(320,120,340,130);
 
 rect(190,80,210,120);
 
 stroke(0);
 fill(190,190,190);
 rect(80,118,320,150);
 rect(155,118,245,280);

 ellipseMode(CORNERS);
 ellipse(165,35,235,105);
 noStroke();
 
 ellipseMode(CENTER);
 fill(150,110,50);
 arc(200, 70, 70, 70,0, PI);
 
 fill(190,190,190);
 rect(195,70,205,90);
 
 fill(100,100,100);
 rect(165,63,235,70);
 
 fill(120,120,120);
 ellipse(170,66.5,3,3);
 ellipse(180,66.5,3,3);
 ellipse(190,66.5,3,3);
 ellipse(200,66.5,3,3);
 ellipse(210,66.5,3,3);
 ellipse(220,66.5,3,3);
 ellipse(230,66.5,3,3);
 
 fill(255);
 ellipse(210,50,10,10);
 
 fill(0,175,10);
 triangle(350,340,360,350,355,350);
 triangle(360,350,370,350,370,320);
 triangle(365,350,370,350,380,330);
 triangle(370,350,375,350,390,330);
 
 stroke(70,40,0);
 noFill();
 strokeWeight(2);
 line(215,300,215,345);
 line(205,282,205,320);
 line(200,300,200,335);
 line(190,290,190,325);
 line(190,330,190,346);
 line(185,282,185,310);
 
 line(195,107,195,110);
line(200,111,200,116);
line(205,108,205,114);

line(338,122,330,122);
line(322,126,332,126);

line(61,122,73,122);
line(61,126,69,126);

stroke(95,95,95);
line(80,120,100,150);
line(100,120,120,150);
line(120,120,140,150);
line(140,120,245,275);
line(155,173,226,280);
line(155,202,205,280);
line(155,235,185,280);
line(160,120,245,247);
line(180,120,245,215);
line(200,120,245,185);
line(220,120,245,155);
line(240,120,260,150);
line(260,120,280,150);
line(280,120,300,150);
line(300,120,320,150);

line(320,120,300,150);
line(300,120,280,150);
line(280,120,260,150);
line(260,120,156,276);
line(240,120,156,244);
line(220,120,154,218);
line(200,120,154,188);
line(180,120,155,154);
line(160,120,140,150);
line(140,120,120,150);
line(120,120,100,150);
line(100,120,80,150);
line(244,178,175,280);
line(244,207,195,280);
line(244,235,215,280);

fill(0,175,10);
noStroke();
triangle(230,330,220,350,215,350);
triangle(230,320,215,350,205,350);
triangle(210,320,205,350,195,350);
triangle(212,330,210,350,205,350);
triangle(190,330,210,350,205,350);
triangle(195,350,190,350,180,320);
triangle(190,350,180,350,170,330);
triangle(170,330,168,335,172,332);
triangle(180,350,160,340,190,350);


ellipseMode(CENTER);
  //covering the scleras
  noStroke(); 
  fill(150,110,50);
  ellipse(184,80,18.5,18.5);
  ellipse(216,80,18.5,18.5);
// lines on the eyes
    stroke(0);
    line(208,80,228,80);
    line(208,80,225,70);
    line(208,80,225,90);
  
    line(192,80,172,80);
    line(192,80,175,70);
    line(192,80,175,90);

//This was the hardest part,
//making the sword tilt
noStroke();
fill(77,46,4);
quad(mouseX+10,mouseY+10,mouseX-10,mouseY-10,mouseX-20,mouseY,mouseX,mouseY+20);
quad(mouseX+11,mouseY-25,mouseX,mouseY-35,mouseX-45,mouseY+8,mouseX-35,mouseY+20);
quad(mouseX-10,mouseY-20,mouseX-70,mouseY-85,mouseX-90,mouseY-65,mouseX-30,mouseY-1);
triangle(mouseX-69,mouseY-84,mouseX-89,mouseY-64,mouseX-95,mouseY-90);
stroke(70,40,0);
line(mouseX-25,mouseY-15,mouseX-85,mouseY-80);
//also added "action lines"
stroke(255);
noFill();
arc(mouseX-5, mouseY-50,100,100, PI+QUARTER_PI, TWO_PI);
arc(mouseX-5, mouseY-30,80,80, PI+QUARTER_PI, TWO_PI);
}

























//while you were reading this, I studied the blade.