ddrmaster1000_ProcessingFiles/Play/Play.pde

// Example: Two Car objects
Car myCar1;
Car myCar2; // Two objects!

void setup() {
  size(200,200);
  // Parameters go inside the parentheses when the object is constructed.
  myCar1 = new Car(color(255,0,0),0,100,2); 
  myCar2 = new Car(color(0,0,255),0,10,1);
}

void draw() {
  background(255);
  myCar1.drive();
  myCar1.display();
  myCar2.drive();
  myCar2.display();
}

// Even though there are multiple objects, we still only need one class. 
// No matter how many cookies we make, only one cookie cutter is needed.
class Car { 
  color c;
  float xpos;
  float ypos;
  float xspeed;

  // The Constructor is defined with arguments.
  Car(color tempC, float tempXpos, float tempYpos, float tempXspeed) { 
    c = tempC;
    xpos = tempXpos;
    ypos = tempYpos;
    xspeed = tempXspeed;
  }

  void display() {
    stroke(0);
    fill(c);
    rectMode(CENTER);
    rect(xpos,ypos,20,10);
  }

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


/*
color c = color(0);
float x = -30;
float y = 0;
float speed = 1;
Car myCar;

void setup(){
size(200,200);
myCar = new Car();
  
}



void draw(){
  background(255);
  move();
  display();
  
  
  
}

void move(){
 x = x + speed;
 if( x > width){
  x = -30; 
 }
}

void display(){
 fill(c);
 rect(x,y,30,10);
  
}
*/


/*
void draw(){
 line(width/2, height/2, mouseX, mouseY);
  fill(0,200,0);
 rect(50,50, 100, 100);
   fill(0,200,200);
 ellipse(300,300, 50, 150);

}

void mousePressed(){
  background(192, 64, 0); 

  
}
*/