> show canvas only <


/* built with Studio Sketchpad: 
 *   https://sketchpad.cc
 * 
 * observe the evolution of this sketch: 
 *   https://cst1101.sketchpad.cc/sp/pad/view/ro.WEcN9Q5tf3l/rev.190
 * 
 * authors: 
 *   Bikkaram Singh

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



Train myTrain; // object data type
Train myTrain2;
int number; // int data type
 
Person [] people;
 
/* @pjs preload="/static/uploaded_resources/p.3300/Rat2.png"; */
 
PImage img = loadImage("/static/uploaded_resources/p.3300/Rat2.png");
 
void setup() {
  people = new Person [110];
  for (int i = 0; i < people.length; i++) {
    people[i] = new Person(220, 155, 1, int(random(0, 4)), int(random(50,100)), int(random(50,100)));
  }
  size(700, 700);
  myTrain = new Train("A - Lefferts Bl", color(140), 90, 100, 5, 100); // calls constructor
  myTrain2 = new Train("F - Coney Island", color(140), 150, 300, 3, 100);
  number = 100; // init variable
}
 
void draw() {
  background(0, 0, 255);
  
    //A Track
  line(50, 100, 50, 150);
  line(100, 100, 100, 150);
  line(150, 100, 150, 150);
  line(200, 100, 200, 150);
  line(250, 100, 250, 150);
  line(300, 100, 300, 150);
  line(350, 100, 350, 150);
  line(400, 100, 400, 150);
  line(450, 100, 450, 150);
  line(500, 100, 500, 150);
  line(550, 100, 550, 150);
  line(600, 100, 600, 150);
  line(650, 100, 650, 150);
  line(700, 100, 700, 150);
 
  //F Track
  line(50, 300, 50, 350);
  line(100, 300, 100, 350);
  line(150, 300, 150, 350);
  line(200, 300, 200, 350);
  line(250, 300, 250, 350);
  line(300, 300, 300, 350);
  line(350, 300, 350, 350);
  line(400, 300, 400, 350);
  line(450, 300, 450, 350);
  line(500, 300, 500, 350);
  line(550, 300, 550, 350);
  line(600, 300, 600, 350);
  line(650, 300, 650, 350);
  line(700, 300, 700, 350);
 
 
  fill(150); 
  rect(0, 150, width, 150);
 
  fill(255);
  line(280, 260, 280, 230);
  line(180, 260, 180, 230);
 
  fill(0);
  rect(180, 220, 100, 25);
  rect(60, 160, 500, 20);
  rect(60, 270, 500, 20);
 
  //STAIRS
  rect(0, 180, 10, 100);
  rect(8, 180, 10, 100);
  rect(16, 180, 10, 100);
  rect(680, 180, 10, 100);
  rect(688, 180, 10, 100);
  rect(696, 180, 10, 100);
 
  //EXIT 
  fill(255, 0, 0);
  rect(530, 210, 120, 35);
  rect(37, 210, 122, 35);
  fill(255);
  text("EXIT ---->", 560, 225);
  text("Fulton St & Jay St", 535, 240);
  text("<---- EXIT", 40, 225);
  text("Jay St & Willoughby St", 37, 243);
 
  //R train
  fill(254, 254, 34);
  ellipse(124, 223, 20, 20);
  fill(0);
  text("R", 120, 227);
 
  fill(0, 0, 255);
  ellipse(70, 170, 20, 20);
  ellipse(292, 170, 20, 20);
 
  fill(255, 165, 0);
  ellipse(70, 280, 20, 20);
 
  fill(255, 255, 0);
  rect(0, 151, width, 3);
  rect(0, 301, width, 3);
  
  
  fill(255);
  rect(300,200,70,50);
  rect(0, 90, width, 10);
  rect(0, 350, width, 10);
  text("Jay St - MetroTech", 180, 240);  
  text("A", 67, 175);
  text("C", 287, 175);
  text("Far Rckwy or Lefferts Blvd (Express)", 83, 175);
  text("Euclid Av (Local) - Late Nights take A train", 310, 175);
  text("F", 67, 283);
  text("Coney Island - Stillwell Av, Culver Local, SKIPS SMITH-9th STS", 83, 283);
 
 fill(0,0,255);
  text("7:50 PM", 315, 225);
 
 
 image(img,480,250,50,50);
 
  fill(255);
  myTrain.display();
  myTrain.drive();
  myTrain2.display();
  myTrain2.drive();
 
  for (int i = 0; i < people.length; i++) {
    people[i].walk();
    people[i].display();
  }
}
 
class Person {
  int personX; 
  int personY;
  int personSpeed;
  int personDirection;
  int timer;
  int timerVal;
 
  Person(int personX_, int personY_, int personSpeed_, int personDirection_, int timer_, int timerVal_) {
    personX = personX_;
    personY = personY_;
    personSpeed = personSpeed_;
    personDirection = personDirection_;
    timer = timer_;
    timerVal = timerVal_;
  }
 
  void walk() {
    timer = timer - 1;
    if (timer == 0) {
      timer = timerVal;
      personDirection = int(random(0, 3));
    }
    if (personDirection == 0) {
      // doesnt move
    }
    if (personDirection == 1) {
      // walk one way
      personX++;
    }
    if (personDirection == 2) {
      // walk one way
      personX--;
    }
    if (personDirection == 3) {
      // walk one way
      personY++;
    }
    if (personDirection == 4) {
      // walk one way
      personY--;
    }
    
  }
  void display() {
    fill(255);
    ellipse(personX, personY, 10, 10);
  }
}
 
class Train {
  color trainColor; // data
  int trainA;
  int trainF;
  int trainSpeed;
  int trainSize;
  String let;
 
  Train(String let_, color trainColor_, int trainA_, int trainF_, int trainSpeed_, int trainSize_) { // constructor
    trainColor = trainColor_;
    trainA = trainA_;
    trainF = trainF_;
    trainSpeed = trainSpeed_;
    trainSize = trainSize_;
    let = let_;
  }
 
  void drive() { // methods
    trainA = trainA + trainSpeed;
  }
 
  void display() { // methods
    fill(trainColor);
    stroke(255);
    rect(trainA, trainF, trainSize, trainSize/2);
    fill(255, 165, 0);
    text(let, trainA, trainF+10);
  }
}
 
void mousePressed() {
   image(img, mouseX, mouseY, 40, 40);
}