topical media & game development

talk show tell print

graphic-processing-learning-06-example-6-8-example-6-8.pde / pde



  // Learning Processing
  // Daniel Shiffman
  // http://www.learningprocessing.com
  
  // Example 6-8: Lines one at a time
  
   // No for loop here. Instead, a global variable.
  int y = 0;
  
  void setup() {
    size(200,200);
    background(255);
    // Slowing down the frame rate so we can easily see the effect.
    frameRate(5); 
  }
  
  void draw() {
    // Draw a line
    stroke(0);
    // Only one line is drawn each time through draw().
    line(0,y,width,y); 
    // Increment y
    y += 10;
    
    // Reset y back to 0 when it gets to the bottom of window
    if (y > height) {
      y = 0;
    }
  }
  


(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.