(P0) Justin Edmund

by jedmund @ 11:42 pm 12 January 2010

Sinuoids

View Sinusoids

float x, y;
float amplitude = 30.0;
float offsetX, offsetY;
float period;
 
void setup() {
  size(640, 600);
  background(255);
}
 
void draw() {
  stroke(0);
  noFill();
  drawNollSinuoids();
 
  println("Finished.");
  exit();
}
 
void drawNollSinuoids() {
  for (int i = 0; i < 90; i++) {
    // Set the period (reciprocal of frequency) to that of the first curve.
    // offsetY pushes the sine curve into the view and then incrementally pushes it down farther
    // to create the optical illusion.
    period = 30 / PI;
    offsetY = 50 + i * 5.5;
    offsetX = PI;
 
    // Begin the shape for this line.
    beginShape();
 
    for (x = 0; x < width; x++) {
      // The first part of this equation sets the position of the line so that we get 90 iterations.
      // y = a sin(bx + c) + d where
      // y = a sin(x/b + c) + d
      // a = amplitude,
      // b = frequency,
      // c = x offset,
      // d = y offset
 
      // Create the curve equation.
      // We offset the X by PI to push it to the left one period for the desired effect. 
      y = sin(x / period + offsetX);
 
      // Reverse the x values so that we get the higher frequency waves first, and lower frequency waves gradually,
      // then create the vector point.
      vertex(x, amplitude * y + offsetY);  
 
      // Increment the period
      period += 0.038;
    }  
    // End the shape for this line.
    endShape();
  }
}

Pong (1.0)
This version uses keyboard navigation (Up and Down keys).

Go see Pong (1.0).
View source (1.1)
View source (1.0)

Changes

  • Added scores (in console)
  • Fixed enemy AI

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License.
(c) 2016 Special Topics in Interactive Art & Computational Design | powered by WordPress with Barecity