fabianmoronzirfas
11/13/2013 - 9:42 AM

This sketch is part of the course ["Eingabe, Ausgabe. Grundlagen der prozessorientierten Gestaltung"](https://incom.org/workspace/4693) by M

This sketch is part of the course "Eingabe, Ausgabe. Grundlagen der prozessorientierten Gestaltung" by Monika Hoinkis

// using_classes
Particle ptcl; // define a new Particle

void setup() {

  ptcl = new Particle(width/2, height/2, 10, 10);// initialize it
}

void draw() {
  // call its functions
  ptcl.display();
  ptcl.update();
}

/**
 * The particle class
 */
class Particle {
  int w, h;
  float x, y;
  int rotation = 0;
  //--------------------------------------
  //  CONSTRUCTOR
  //--------------------------------------
  Particle (float _x, float _y, int _w, int _h) {
    this.x = _x;
    this.y = _y;
    this.w = _w;
    this.h = _h;
  }

  //Show it
  void display() {
    pushMatrix();
    translate(this.x, this.y);
    rectMode(CENTER);
    rotate(radians(rotation));// rotate it
    rect(0, 0, this.w, this.h);
    popMatrix();
  }
  // update its state
  void update() {
    rotation++;
  }
}