//MY HOUSE
//Created by Gary Munoz-Villarreal

float sunX=50,sunY=50; // initiating float
float dogX,dogY;
float heroX,heroY;
float birdX=10,birdY=10;
float bombX=50, bombY=50;
float bunnyX=40, bunnyY=500, bunnyDX, bunnyDY;  
float bombV=0;
float gravity= 9;
  
  void setup(){  

  // DRAW BOX
  size( 600, 600);
  bunnyDX=5; bunnyDY=0;        //bunny movement variable
  }

  void draw() {
    // coloring sky
  background( 0, 191, 255);

  // DRAWING AND COLORING SUN
  fill( 255, 255, 0);
  ellipse(sunX, sunY, 90, 90); 


   //movement:  sun crosses sky, reset to left side.
   if (sunX > width) {
   sunX=  50;
   }
   sunX=  sunX + 1;
   
    // creating bird
  fill(220,20,60);
  triangle(birdX,birdY,birdX+85,birdY+30,birdX,birdY+50);
  
    //movement:  bird crosses sky, reset to left side.
   if (birdX > width) {
   birdX=  0;
   }
   birdX=  birdX + 3;
  
  
  
  // drawing bomb
  fill(128,128,128); 
  ellipse(bombX+20,bombY+30,25,25);
  // bomb attached to bird
  bombX= bombX + (birdX-bombX);
  bombY= bombY + (birdY-bombY);
  
  if (bombY < height) {      // Accelerate bomb, unless it is off the screen.
    bombV=  bombV + gravity;
    bombY = bombY + bombV;
  }
  
  //drawing grass
  fill(0, 128, 0);
  rect(0, 400, 600, 400);

  //drawing tree trunk & leaves & branches
  fill(139, 69, 19);
  rect(25, 200, 50, 200);
  fill(107, 142, 35);
  ellipse(50, 200, 150, 50); 
  line(50, 300, 110, 300);
  line(50, 350, 110, 350);
  line(50, 250, 110, 250);

  //creating house & coloring
  fill(25, 25, 112);
  rect(485, 350, 100, 50);
  fill(138, 43, 226);
  triangle(485, 350, 585, 350, 535, 240);

  
  // red orange bunny
  fill( 255, 69, 0);      
  ellipse( bunnyX, bunnyY, 100, 40 );
  fill( 0 );
  line( bunnyX-25, bunnyY+5, bunnyX-27, bunnyY+20 );
  line( bunnyX-20, bunnyY+5, bunnyX-22, bunnyY+20 );
  // front legs
  line( bunnyX+25, bunnyY+5, bunnyX+27, bunnyY+20 );
  line( bunnyX+20, bunnyY+5, bunnyX+22, bunnyY+20 );
  
  
  // bunny moves left to right
  bunnyX = bunnyX + bunnyDX;
  if (bunnyX > width) {
    bunnyDX=  - bunnyDX;      // Reverse direction at right.
  }
  if (bunnyX < 0) {
    bunnyDX=  - bunnyDX;      // Reverse direction at left.
  }
  
  // Set ellipses and rects to CENTER mode 
  
  //creating gold hero basic
  fill(225, 215, 0);
  rect(mouseX-25, mouseY, 50, 100);
  ellipse(mouseX, mouseY-30, 60, 60);
  // creating hero variable
  heroX=mouseX;
  heroY=mouseY;
  
  //creating black dog
  fill(0, 0, 0);
  ellipse(dogX, dogY, 125, 50);
  fill(0, 0, 0);
  ellipse(dogX-75, dogY, 50, 50);
  line(dogX-25, dogY, dogX-30, dogY+65);
  line(dogX-45, dogY, dogX-50, dogY+65);
  line(dogX+25, dogY, dogX+25, dogY+65);
  line(dogX+45, dogY, dogX+45, dogY+65);
   
   
   dogX= dogX + (heroX-dogX) /100;
   dogY= dogY + (heroY-dogY)/100;
   

  //Text name in lower right and title in center
  textSize(40);
  fill(0, 0, 0);
  text("Welcome to my home", 150, 150);
  textSize(30);
  fill(139, 0, 139);
  text("Gary Munoz-Villarreal", 270, 575);
  }
  
  //// key operations ////
  void keyPressed() {
  if (key == '+') {  bunnyDX = .1 * bunnyX; }
  if (key == '-') {  bunnyDX = 0.91 * bunnyDX; }
  
  if (key == 'b') {  bombY=1; }
  if (key == 'b') { bombV=0;}
  }
