//very simple program of animating fish that "swims" across the screen

//variables to move the fish
int tx, ty;

//a function to set up the general drawing parameters
void setup() {
  size(400, 200);
  background(#579D5F);
  smooth();
  tx = 400;
  ty = 100;
  frameRate(20);
}

//press any key to reset the fish
void keyPressed() {
  tx = 400;
  ty = 100;
}

//function to draw the fish
void drawFish() {
  fill(#F5910F);
  stroke(0);
  ellipse(0, 0, 30, 10);
  triangle(15, 0, 28, -10, 28, 10);
  stroke(255);
  fill(0);
  rect(-10, -3, 4, 2);
}
  

//the draw function - which will loop
void draw() {
  
  background(#579D5F);
  
  //draw the fish in an updated position using variables
  pushMatrix();
  translate(tx, ty);
  drawFish();
  popMatrix();
  
  //update my variables - either randomly update y or use sin
  tx = tx - 1;
  //ty = ty + int(random(-5, 5));
  ty = 100 + int(30*sin(tx/400.0*6*PI));
}