> show canvas only <


/* built with Studio Sketchpad: 
 *   https://sketchpad.cc
 * 
 * observe the evolution of this sketch: 
 *   https://cst1101.sketchpad.cc/sp/pad/view/ro.SsqKmqMLZ15/rev.10
 * 
 * authors: 
 *   Gregory Clena

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



Vessel the_Vessel;
Vessel [] port;


void setup() {
   port = new Vessel [30]; // 30 reserved landing spot.
 size(400, 300);
  for(int i = 0; i < port.length; i++){
  port[i] = new Vessel(color(i,255,255), 100, 100, 0, 100, 100, 100, i/4);

  frameRate(2);
  }
}
void draw () {
  background(0);
  for(int i = 0; i < port.length; i++){
  port[i].fluctuate();  
   port[i].show();
  } 
}
class Vessel { //Data : the contents of the vessel
  int centerX;
  int centerY;
  int girth;

  // top point 
  int vessel_ax;
  int vessel_ay;

  //left point 
  int vessel_bx;
  int vessel_by;

  //right point 
  int vessel_cx;
  int vessel_cy;
  int vesselSpeed;
  color vesselCol;
  boolean grow = false;

  // The Constructor: putting all the parts of the vessel together
  Vessel(color vesselCol_, int vessel_ax_, int vessel_ay_, int vessel_bx_, int vessel_by_, int vessel_cx_, int vessel_cy_, int vessel_speed_) {

    centerX = width/2;
    centerY = height/2;
    girth = centerY;
    vesselSpeed = vessel_speed_;
    vesselCol = vesselCol_;

    // top point - Starting high
    vessel_ax = vessel_ax_;
    vessel_ay = vessel_ay_;

    //left point - Starting wide
    vessel_bx = vessel_bx_;
    vessel_by = vessel_by_;
    //right point - Starting wide
    vessel_cx = vessel_cx_;
    vessel_cy = vessel_cy_;
  }
  void fluctuate() {  // assigning the movement of the vessel
    // Shrinking/Growing top point
    vessel_ax = centerX; 
    vessel_ay = centerY - girth; 

    // Shrinking/Growing left point
    vessel_bx = centerX - girth;
    vessel_by = centerY + girth;

    // Shrinking/Growing right point
    vessel_cx = centerX + girth;
    vessel_cy = vessel_by;

    if (grow) {
      girth = girth + vesselSpeed; // if boolean is true
      
    }
    else {
      girth = girth - vesselSpeed; // if boolean is false
      
    }
    if (girth < 5) {
      grow = true;
    }
    if ( girth > centerY ) {
      grow = false;
    }
    
  }

  void show() { // Displaying the vessel
    stroke(vesselCol);
    fill(0,20);
    triangle(vessel_ax, vessel_ay, vessel_bx, vessel_by, vessel_cx, vessel_cy);
  }
}