GPN8:Processing-Workshop: Unterschied zwischen den Versionen

aus dem Wiki des Entropia e.V., CCC Karlsruhe
K (Kategorie hinzugefuegt)
K (hat „ProcessingWorkshop“ nach „GPN8:Processing-Workshop“ verschoben)
 
(5 dazwischenliegende Versionen von 2 Benutzern werden nicht angezeigt)
Zeile 1: Zeile 1:
==CAR==
* [http://todbot.com/blog/wp-content/uploads/2006/10/arduino_spooky_projects_class4.pdf Arduino&Processing]
 
* [http://todbot.com/blog/bionicarduino/ Beispiele & PDFs]
int anzahl_autos = 50;
* [[Media:Processing.zip|Processing.zip]]
Car[] autos = new Car[anzahl_autos];
* [[Media:Ap_ReadAnalog.zip|Ap_ReadAnalog.zip]]
 
* [[Media:Tree.zip|Tree.zip]]
void setup(){
  size(300,400);
  for(int i = 0; i < anzahl_autos; i++) {
    autos[i] = new Car(color(0,1,1),random(100),random(height),random(1,5));
  }
}
 
void draw() {
  background(128);
  for(int i = 0; i < anzahl_autos; i++) {
    autos[i].move();
    autos[i].display();
  }
}
 
--- TEIL2 ---
 
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 move() {
    xpos = xpos + xspeed;
    if (xpos > width) {
      xpos = 0;
    }
  }
}
 


[[Kategorie:GPN8]]
[[Kategorie:GPN8]]

Aktuelle Version vom 18. Juni 2009, 08:26 Uhr