topical media & game development

talk show tell print

graphic-processing-learning-09-example-9-9-example-9-9.pde / pde



  // Learning Processing
  // Daniel Shiffman
  // http://www.learningprocessing.com
  
  // Example 9-9: An array of Car objects
  
  Car[] cars = new Car[100]; // An array of 100 Car objects!
  
  void setup() {
    size(200,200);
    smooth();
    for (int i = 0; i < cars.length; i ++ ) { // Initialize each Car using a for loop.
      cars[i] = new Car(color(i*2),0,i*2,i/20.0); 
    }
  }
  
  void draw() {
    background(255);
    for (int i = 0; i < cars.length; i ++ ) { // Run each Car using a for loop.
      cars[i].move();
      cars[i].display();
    }
  }
  


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.