//Yuriy Burshtyko
//In class project
float sealevel, chop=40,waveX=0,fishX,fishY,fishDX=3,left,right;
float sunX,sunY;
int numfishes=3;


void setup() {
    size( 1000,800 );
  sealevel=  height/4;
  left=0;
  fishX=0;
  fishY=random(sealevel,height);
  
}
void reset(){
  fishX=250;
  fishY=random(sealevel,height);
  sunX=0;
  sunY=sealevel*2/3;
}
  
void draw() {
  skyandgrass();
  waves();
  waveX = (waveX-1) % chop;
  sun();
  sunX= ( sunX + 2) % width;
  fishes(numfishes);
  fishX +=fishDX;
  
  if(fishX>width ||fishX<left) {
    fishDX= -fishDX;
    fishY = random(sealevel, height);
   
}}
void skyandgrass() {
  background( #15A3FF);
  fill( #1EBC49); 

rectMode( CORNER );
  rect(0,sealevel, width,height*3/4);
}


void waves(){
  float x,y;
  y=sealevel;
  for(  x=waveX; x<width+chop; x=x+chop)
  {
    noStroke();
    fill( #15A3FF);
    ellipse(x,y,chop,chop);

  }
}
void sun() {
    // make sun
       fill(#FAF13F);
    ellipse(sunX,sunY,75,75);}
    
    
    void fishes( int many ) {
  //school of fish swim back and forth
  float x= fishX, y=fishY;
 for (int j=0; j<many; j++) {
   fill(#3C3E25);
   ellipse(fishX, fishY, 80,50);
   x= fishX -90;
     fill(0);

  
  if(fishDX<0)
    ellipse(x+65, y-15,10,10);
    
  if(fishDX>0)
     ellipse(x+120, y-15,10,10);
   
  }
}

