> show canvas only <


/* built with Studio Sketchpad: 
 *   https://sketchpad.cc
 * 
 * observe the evolution of this sketch: 
 *   https://uclaspring12.sketchpad.cc/sp/pad/view/ro.dVWCgBhFsGP/rev.95
 * 
 * authors: 
 *   Michelle Lin
 *   Casey Reas

 * license (unless otherwise specified): 
 *   creative commons attribution-share alike 3.0 license.
 *   https://creativecommons.org/licenses/by-sa/3.0/ 
 */ 



// S U B M A R I N E   IN   M O T I O N
// all fish courtesy of clipart etc

/* @pjs preload="/static/uploaded_resources/p.4528/1.gif"; */
/* @pjs preload="/static/uploaded_resources/p.4528/2.gif"; */
/* @pjs preload="/static/uploaded_resources/p.4528/3.gif"; */
/* @pjs preload="/static/uploaded_resources/p.4528/4.gif"; */
/* @pjs preload="/static/uploaded_resources/p.4528/5.gif"; */
/* @pjs preload="/static/uploaded_resources/p.4528/6.gif"; */
/* @pjs preload="/static/uploaded_resources/p.4528/7.gif"; */
/* @pjs preload="/static/uploaded_resources/p.4528/8.gif"; */
/* @pjs preload="/static/uploaded_resources/p.4528/9.gif"; */
/* @pjs preload="/static/uploaded_resources/p.4528/10.gif"; */
/* @pjs preload="/static/uploaded_resources/p.4528/11.gif"; */
/* @pjs preload="/static/uploaded_resources/p.4528/12.gif"; */
/* @pjs preload="/static/uploaded_resources/p.4528/sub_back_3.png"; */




PImage subm;
PImage[] images = new PImage[12];

int i = 1;
int t = 1000;
int time1 = t;
int time2 = 3*t;
int time3 = 6*t;
int time4 = 4*t;
int time5 = 7*t;
int time6 = 9*t;
int time7 = 12*t;
int time8 = 16*t;

// x positions
   float x = 0;
   float x1 = 0;
   float x2 = 0;
   float x3 = 0;
   float x4 = 0;
   float x5 = 0;
   float x6 = 1200;
   float x7 = 0;
   float x8 = 1200;
   
  

  
// speed
  float angle = 0.0;
  float angle2 = 0.0;

   


void setup() {
  size(1200, 300);
  frameRate(30);  // remember to look up how to set speed
  smooth();
  for( int i = 1; i < images.length; i++) {
    images[i] = loadImage( "/static/uploaded_resources/p.4528/" + i + ".gif" );
  }
  subm = loadImage("/static/uploaded_resources/p.4528/sub_back_3.png");
  
  fill(199, 214, 237);
  rect(0, 0, 1200, 300);
  
  image(subm, 0, 0);

}

void draw() {
    
  // -----------------------------------------
  int currentTime = millis();
  
  float sinval = sin(angle);
  float sinval2 = sin(angle2);
  
  // background fill -------------------------
  
  fill(199, 214, 237);
  rect(0, 0, 1200, 300);
    
   
  // FISH 1.GIF-------------------------------
  float speed = map(sinval, -1, 1, 0.3, 2.5);
  angle += 0.1;
  
  if (currentTime > time1); {
    x1 += speed;
    image(images[(int)(1)], x1, 140, 40, 40);
  } if (x1 > width) {
    x1 = 0;
    }

  fill(199, 214, 237, 40);
  rect(0, 0, 1200, 300);
    
 
  // FISH 3.GIF (EEL) ------------------------
  float eelY = map(sinval, -1, 1, 160, 180);  
  if (currentTime > time2) {
    x2 += 2.5;
    image(images[(int)(3)], x2, eelY, 80, 80);
  } if (x2 > width) {
    x2 = 0;
    }
    
    fill(199, 214, 237, 60);
    rect(0, 0, 1200, 300);
    
   // FISH 4.GIF (FLOUNDER?) -----------
  float speed4 = map(sinval, 1, -1, 0.7, 3.7);
  if (currentTime > time1); {
    x6 -= speed4;
    image(images[(int)(4)], x6, 125, 75, 75);
  } if (x6 < 0) {
    x6 = 1200;
    }    
    
    
    fill(199, 214, 237, 10);
    rect(0, 0, 1200, 300);
    
    
  // FISH 3.GIF (EEL2)-------------------------  
    float eel2Y = map(sinval, 1, -1, 50, 75);
    if (currentTime > time3) {
      x4 += 1.8;
      image(images[(int)(3)], x4-40, eel2Y, 100, 100);
    } if (x4 > width) {
    x4 = 0;
    }
    
    
    fill(199, 214, 237, 40);
    rect(0, 0, 1200, 300);
    
    
  // FISH 8.GIF (SHARK) -----------
  angle2 += 0.03;
  float y8 = map(sinval2, 1, -1, 1000, 200);
  if (currentTime > time4); {
    x8 -= 3.0;
    image(images[(int)(8)], x8, y8, 125, 125);
  } if (x8 < 0) {
    x8 = 1200;
    }   
    

  // FISH 5.GIF (PUFFERFISH)----------------------  
  float speed5 = map(sinval, 1, -1, 1.0, 5.0);
  float size1 = map(sinval, -1, 1, 80, 60);
  
  if (currentTime > time1); {
    x7 += speed5;
    image(images[(int)(5)], x7, 150, size1, size1);
  } if (x7 > width) {
    x7 = 0;
    }  

    
    
    fill(199, 214, 237, 40);
    rect(0, 0, 1200, 300);


    
   // FISH 2.GIF (ANGLERFISH) ------------------
    
    if (currentTime > time1) {
      x3 += 1.2;
      image(images[(int)(2)], x3-150, 95, 200, 200);
    } if (x2 > width) {
      x2 = 0;
      }
  
    fill(199, 214, 237, 60);
    rect(0, 0, 1200, 300);


  // FISH 5.GIF (TROUT?) -------------------------
    float speed3 = map(sinval, 1, -1, 0.5, 3.5);
    if (currentTime > time3) {
      x5 += speed3;
      image(images[(int)(1)], x5-50, 80, 100, 100);
    } if (x5 > width) {
      x5 = 0;
      }

    
    // BACKGROUND
    image(subm, 0, 0);
    
}