
//midterm
//author: christopher esposito

boolean day;

float x,y,w,h;
float birdX=50, birdY=50;
float horizon;
float sunX=100, sunY=100;
float witchX, witchY;
float octopusX, octopusY;

void setup() {
  
  size(600,500);
  horizon= height/3;
  sunY= horizon/3.5;
  witchY= horizon/1.5;
  witchX= width/8.5;
  octopusX= width/3;
  octopusY= horizon+250;
  x= width/2;
  y= horizon-100;
  w= 60;
  h= 20;
  day=true;
  }
void draw() {
  //next frame //
  scene();
  reset();
  buttons();
  if (day){
    bird();
  } else {
      witch();
      octopus();
  }
  textSize(12);
  fill(0);
  text("CST 112 MIDTERM",height/2,width/15);
}
void scene() {
  //background //
  if (day){
  background(0,255,255); //day
  fill(255,255,0);  //sun
  ellipse(sunX, sunY, 50,50);
  } else {                            //figure out why it wont change from day to night
    background(0,94,255); // night
    fill (200,170,210); //moon
    ellipse(sunX, sunY, 50,50);
  }
  fill(255,255,0);  //sun
  ellipse(sunX, sunY, 50,50);
  fill(10,145,0); //ocean
  rectMode( CORNER );
  rect(0, horizon, width, height*3/4);
  if (sunX  > width) {
    sunX=0;
    sunY= random(30, horizon-30);
  }
  sunX= sunX+2.5;
  
}

void bird() {
  float x=birdX+30, w=60, h=15;
  fill(255,0,255);
  //bird
  float birdY= horizon-50;
  fill(145,40,130);
  triangle(birdX,birdY, birdX-w,birdY-h, birdX-w,birdY+h);
  triangle(birdX-25,birdY, birdX-w,birdY-h-15, birdX-w,birdY+h+25);
  
  noStroke();
  birdX= (birdX+3.5) % width; //makes bird move
}

void witch(){
  //draw witch
  //float witchX= width-50;
  float witchY= horizon-100;
  
  //body
  fill(150,100,50);
  rect(witchX,witchY, 25,50);
  
  //head
  fill(255,0,0);
  ellipse(witchX+13,witchY-10, 25,25);
  
  //legs
  fill(0,255,0);
  rect(witchX,witchY+50, 10,25);
  rect(witchX+15,witchY+50, 10,25);
 
  //hat
  strokeWeight(3);
  stroke(0);
  line(witchX-10,witchY-15, witchX+30,witchY-15);
  fill(0);
  triangle(witchX,witchY-15, witchX+25,witchY-15, witchX+15,witchY-35 );
  
  //broom
  Broomstick( witchX-25, witchX+50, witchY+50 );
  
  //make witch move
  witchX= (witchX-2); 
  if (witchX < -75){
  day= true;  
  reset();
  }
}
void Broomstick( float x1, float x2, float y ) {
  //// Broom rrr
  strokeWeight(6);
  stroke(200,150,100);
  line( x1, y, x2, y );
  // bristles
  strokeWeight(2);
  float yy=  y-10;
  for (int j=0; j<7; j++ )
  {
    line( x2,y, x2+25,yy );
    yy += 4;
  }
  noStroke();        
}

void octopus() {

  
  noStroke();
 // body of octopus
 fill(205,0,255);
 rect(octopusX,octopusY, 25,25);
 
 // head of octopus
   fill(205,0,255);
  ellipse(octopusX+12.5,octopusY, 25,25);
  
}

void nighttime(){

}

void daytime(){

}
void reset(){

}

void buttons(){
}
