class

Februar 4, 2007

 

/*Declare and contruct two objects
(h1, h2) from the class HLine*/
HLine h1 = new HLine(20, 2.0);
HLine h2 = new HLine(50, 2.5); 

void setup()
{
  size(200, 200);
  framerate(30);
}

void draw() {
  background(204);
  h1.update();
  h2.update();
} 

class HLine {
  float ypos, speed;
  HLine (float y, float s) {
    ypos = y;
    speed = s;
  }
  void update() {
    ypos += speed;
    if (ypos > width) {
      ypos = 0;
    }
    line(0, ypos, width, ypos);
  }
}

Entry Filed under: Processing code. .

Leave a Comment

Required

Required, hidden

Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Trackback this post  |  Subscribe to the comments via RSS Feed


Kategorien

Archive

Links