// Eduardo Rodriguez  CST 112  Project #1 
// Zach vs the monster  
// Global Declarations 

float monsterX, monsterY; //Monster 
float horizon; 
float sunX, sunY; //Sun 
float zachX, zachY; //Hero 
float houseX, houseY // House
// setup contains the size, Sets up the horizon, Sun. 
void setup() {
size(640, 480); // size of window
sunX = width * 5/6; 
sunY = height / 8; 
monsterX = width * 4/5; 
monsterY = height * 4/5; 
horizon = height / 4; 
zachX = mouseX; 
zachY = mouseY; 
houseX = width * 1/2; 
houseY = horizon-30;
} 
// draw the new frame it loops the Scene, Sun, monster, and zach
void draw() { 
  scene(); 
  monster(); 
  zach(); 
} 

void scene() { 
  // The sun, sky, grass, and house will be here. 
  background(30, 118, 229); //The sky 
   
   // The sun moving 
   sunX = sunX-1 % width; 
   sunY = sunY-0.1; 
   
  // The Sun 
  fill (255, 248, 13); 
  ellipseMode( CORNER); 
  ellipse( sunX, sunY, 70, 70); 
  
  // grass
  fill( 20, 198, 8); 
  rectMode (CORNER); 
  rect( 0, height, * 1/3, width, height* 3/4); 
  
  //house
  
 houseX = width * 1/2; 
houseY = horizon-30;
  fill( 198, 8, 167); 
  rectMode(CORNER); 
  rect( houseX, houseY, 150, 70); 

triangle( houseX, houseY, houseX+100, houseY, houseX+50, houseY-25); 

void monster() { 
  monsterX= monsterX + (zachX-monsterX) / 35; 
  monsterY= monsterY + (zachY-monsterY) / 35; 
  monsterY= monsterY<horizon-20 ? horizon+20 : monsterY; 
 
  fill(0); 
 ellipse( monsterX, monsterY, 150, 100); 
fill(255); 
ellipse( monsterX, monsterY, 40, 40); 
fill(100,100,255); 
ellipse( monsterX+(mouseX-pmouseX)/10, monsterY+(mouseY-pmouseY)/5, 15, 15); 
} 

void zach() { 
  
  zachX= zachX + (mouseX-zachX)/15; 
  zachY= mouseY +(mouseX-zachX)/15;
  
  fill( 255, 0, 0); 
  rectMode(CENTER); 
  rect( zachX, zachY, 40, 90); 
  float shoulder= zachY-50; 
  float headY= shoulder-15; 
  float hip = zachY+50; 
  float tilt= (mouseX-pmouseX); 
  
  //Head 
  ellipse( zachX,headY, 30,30 );
      fill( 255 );
      ellipse( zachX-6,headY, 15,10 );
      ellipse( zachX+6,headY, 15,10 );
      fill( 0,150,0 );
      ellipse( zachX-6+tilt/5, headY, 5,5 );
      ellipse( zachX+6, headY, 5,5 );
      
      fill( 255, 0,  0 );
// Legs:  left (-10) & right (+10) tilt toward mosue movement
      stroke(255,0,0);
      strokeWeight(4);
      line( zachX-10,hip, zachX-10+tilt,hip+40 );
      line( zachX+10,hip, zachX+10+tilt,hip+40 );
      strokeWeight(1);
      stroke(0); 
}
  