> show canvas only <


/* built with Studio Sketchpad: 
 *   https://sketchpad.cc
 * 
 * observe the evolution of this sketch: 
 *   https://bard117s14.sketchpad.cc/sp/pad/view/ro.N0NrXmBgXVN/rev.42
 * 
 * authors: 
 *   Daniel
 *   Milo Ben-Amotz
 *   Jessica Boyd
 *   Lucas Baumgart
 *   Liz von Klemperer
 *   Zoe Azulay
 *   Paula Van Erven
 *   Laura Salgarolo
 *   Lauren Harris
 *   Keith O'Hara

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



// Simulation of a Car (From Shiffman's Learning Processing)
// Keith O'Hara <[email protected]>

Bus car1;

void setup() {
  size(500, 200);
  car1 = new Bus(color(255, 255, 0), 50);
}

void draw() {
  background(196);
  car1.drive();
  car1.show();
}

class Bus {
  color c;
  float xpos;
  float ypos;
  float xspeed;

  Bus(color colorp, float y) {
    xspeed = 1;
    c = colorp;
    xpos = random(width);
    ypos = y;
  }

  void drive() {
    xpos = xpos + xspeed;
    if (xpos > width) {
      xpos = 0;
    }
  }

  void show() {
    fill(c);
    rect(xpos, ypos, 20, 10);
  }
}