2011.05.05

Today’s Processing sketch features triangles of various shades flying upwards.

See it in action here!

Pretty simple, eh? The original sketch this came from actually had just one triangle (which I’ll call a ‘spaceship’) which had the x-axis controlled by an Arduino with a potentiometer. This one doesn’t have that.

/*
 * 20110505.pde
 */

void setup() { 
  size(800, 200); 
  frameRate(30);
} 

int yPos = 0; 

void draw() {
  
  background(0);
  stroke(255);
  fill(0);
 
  yPos = yPos - 3;
  if(yPos < 0) {
    yPos = height;
  }

  for (int i = 20; i < 790; i = i+20) {
    int yColor = i/3;
    if (yColor > 255) {
     yColor = 255; 
    }
    stroke(yColor);
    triangle(i, yPos, (i-5), (yPos+10), (i+5), (yPos+10));
  }
  
}

I’d like to go back to the single ship again, and work on adding a starfield which moves past the ship as it maintains it’s vertical position on the screen.

Comments are closed.

« | »


buy the button:

Buy The Button