Project 0

by Nara @ 1:53 am 12 January 2010

Part A

GDE Error: Unable to load profile settings
void draw()
{
  background(#FFFFFF);
  int waveHeight = 30;
  for (int i = 0; i < 90; i++)
  {
    int yOffset = waveHeight + 10 + (i * 8);
    beginShape();
    for (float x = 0; x < 360; x+=5)
    {
      float y = ((TWO_PI*4) * (radians(x)/TWO_PI)) + (PI*3/4);
      curveVertex(sq(x)/120, yOffset + (waveHeight * sin(y)));
    }
    endShape();
  }
}

Part B

I also for the life of me cannot get the iframes to work, so the applet can be found here.

Ball myBall;
Paddle myPaddle;
 
void setup()
{
  size(400, 400);
  rectMode(CENTER);
  ellipseMode(CENTER);
  noStroke();
  fill(#FFFFFF);
  myPaddle = new Paddle();
  myBall = new Ball();
  noCursor();
  smooth();
}
 
void draw()
{
  background(#000000);
  myBall.display();
  myPaddle.display();
  myBall.move();
  if (out()) { myBall.reset(); }
  if (boundaryCollision() || paddleCollision()) { myBall.changeDir(); }
}
 
void mouseMoved()
{
  float hOffset = myPaddle.h / 2;
  myPaddle.ypos = constrain(mouseY, 0 + hOffset, height - hOffset);
}
 
boolean out()
{
  if (myBall.xpos <= 0) { return true; }
  return false;
}
 
boolean boundaryCollision()
{
  if (myBall.xpos <= 0) { return false; }
  if (myBall.ypos <= 0 || myBall.ypos >= height) { return true; }
  if (myBall.xpos >= width) { return true; }
  return false;
}
 
boolean paddleCollision()
{
  float pTop = myPaddle.ypos - (myPaddle.h/2);
  float pBot = myPaddle.ypos + (myPaddle.h/2);
  if (myBall.ypos <= pTop || myBall.ypos >= pBot) { return false; }
  float bLeft = myBall.xpos - (myBall.w/2);
  float pLeft = myPaddle.xpos + (myPaddle.w/2);
  if (bLeft  (pLeft-3)) { return true; }
  return false;
}
 
final class Ball
{
  float xpos = width/2;
  float ypos = height/2;
  float[] dir = {-3, 2};
  int w = 20;
 
  void display()
  {
    ellipse(xpos, ypos, w, w);
  }
 
  void move()
  {
    xpos += dir[0];
    ypos += dir[1];
  }
 
  void changeDir()
  {
    if (ypos <= 0 || ypos >= height) { dir[1] *= -1; }
    else { dir[0] *= -1; }
  }
 
  void reset()
  {
    xpos = width/2;
    ypos = height/2;
    dir = new float[2];
    dir[0] = -3;
    dir[1] = 2;
  }
}
 
final class Paddle
{
  float xpos = 25;
  float ypos = height/2;
  int w = 15;
  int h = 60;
 
  void display()
  {
    rect(xpos, ypos, w, h);
  }
}

project 0

by Cheng @ 10:51 pm 11 January 2010

Part A. Noll Pattern

/* @Cheng 
 @Jan 11, 2010
 Ninety Parallel Sinusoids With Linearly Increasing Period
 http://golancourses.net/2010spring/projects/project-0/
 */
 
import processing.pdf.*;
 
float altitude=20.; // altitude of sine wave
float gain = .0038;  // how fashttp://golancourses.net/2010spring/wp-admin/media-upload.php?post_id=576&TB_iframe=truet the period grow 
float period ; //
float initialPeriod = .55; 
int LeftMargin = 0; // white space 
int upperMargin =5;
 
int x ;
float y ; 
 
smooth();
size (400,410,PDF,"NollSine.pdf");
background (255);
noFill();
strokeWeight(.7);
 
for (int i =0; i<90; i++){
  //point() could induce discrete point;vertext works better 
  beginShape();
  for (x=LeftMargin; x<degrees(width); x++){
    period = initialPeriod+gain* float(x) ; //increase period
    //notice y axis direct downwards; sine wave needs to be reversed
    y = upperMargin + altitude*(-sin(2.*PI*radians(x-LeftMargin)/period)+1.);
    vertex (x,y+i*4);
  }
  endShape();
}

GDE Error: Unable to load profile settings

Part B. Pong Game

WordPress has been constantly deleting the iFrame code, so just click on the link

Jon Miller – Project 0

by Jon Miller @ 4:39 pm

Part A

Notes:
Created in Flash AS3.
PDF created with AlivePDF libraries.

GDE Error: Unable to load profile settings
//static parameters
var startPointY:Number = 39; //starting position of each wave
var amplitude:Number = 30;
 
graphics.lineStyle(1.49, 0, 1);
 
//drawing the sine waves
for(var i:int=0; i<90; i++) {
    graphics.moveTo(0, startPointY);
    angle = -0.1;
    xpos = 0;
    period = 9;
 
    for(var j:int=0; j<1000; j++) {
        xpos++;
        ypos = startPointY - Math.sin(xpos/period) * amplitude;
        graphics.lineTo(xpos, ypos);
        period += 0.0325;
    }
 
    startPointY += 5.8;
}

Part B

Notes:
Created in Flash AS3.
Source code:link
Part of the challenge is scrolling down the page fast enough before the computer gets his first point.

Get Adobe Flash player

Karl DD – Project Zero

by Karl DD @ 3:29 pm

Noll

GDE Error: Unable to load profile settings

P5 APPLET

size(700, 700);
background(255);
smooth();
int yOffset = 50;
int waveHeight = 40;
for(int j = 0; j<90; j++){
  for(int i = 0; i<750; i++){
    float divider = map(i, 0, 749, 10, 35);
    line(i, yOffset + -sin(i / divider) * waveHeight, i+1, yOffset + -sin((i + 1) / divider) * waveHeight);
  }
  yOffset += 6;
}

Pong

I decided to OOP my PONG out a little.
I couldn’t add an IFRAME here because WordPress kept removing it when I saved the draft. So here is the separate page anyway:

P5 PONG

The .pde file links are dead because the .pde file type gets rejected on upload 🙁

PongBall ball;
PongPaddleUser myPaddle;
PongPaddleBot theirPaddle;
 
void setup(){
  size(600, 600);
  rectMode(CENTER_RADIUS);
  ellipseMode(CENTER_RADIUS);
  noStroke();
  smooth();
  myPaddle = new PongPaddleUser(width - PongPaddle.width * 2, height / 2);
  theirPaddle = new PongPaddleBot(PongPaddle.width * 2, height / 2);
  ball = new PongBall(myPaddle, theirPaddle, width / 2, height / 2);
}
 
void draw(){
  background(0);
  ball.draw();
  myPaddle.draw();
  theirPaddle.draw();  
}

FULL PONG SOURCE

project 0 by paul shen

by paulshen @ 3:18 pm

implemented in oF

GDE Error: Unable to load profile settings
void testApp::drawNollSinusoids()
{
    float amplitude = 30.0;
    float phase = PI;
 
    output.setColor(0x333333);
    output.setLineWidth(1.0);
    output.noFill();
    for (int i = 0; i < 90; i++) {
        float period = 30 / PI;
        float offsetY =  15 + i * 5.8;
        output.beginShape();
 
        for (int x = 0; x < windowWidth; x++) {
            float y = sin(x / period + phase);
 
            output.curveVertex(x, amplitude * y + amplitude + offsetY);
            period += 0.031;
        }
        output.endShape();
    }
}

pong

link [ iframe code is removed on update ]

implemented in processing.js

int paddleWidth = 100;
int ballSize = 20;
// all the following deal with center of object
int compPos, userPos;
int ballX, ballY, ballDX, ballDY;
float multiplier = 1.0; // speed up ball
 
void setup() {
  size(400,400);
  frameRate(30);
  noStroke();
 
  resetGame();
}
 
void resetGame() {
  multiplier = 1.0;
  compPos = (height - paddleWidth) / 2;
  userPos = compPos;
  ballX = (width - ballSize) / 2;
  ballY = (height - ballSize) / 2;
  ballDX = 0;
  ballDY = 0;
}
 
void draw() {
  background(#333333);
  fill(#f0f0f0);
 
  // update ball position
  ballX += ballDX * multiplier;
  ballY += ballDY * multiplier;
  multiplier += 0.003;
 
  // check for collision
  // computer side
  if (ballX - ballSize / 2 < 10) {
    if (abs(ballY - compPos)  width - 10) {
    if (abs(ballY - userPos) <= paddleWidth / 2) {
      ballDX = -ballDX;
      ballX = height - 10 - ballSize / 2;
      ballDY += (ballY - userPos) / 5;
    } else {
      resetGame();
    }
  }
  // top
  if (ballY - ballSize / 2  height) {
    ballDY = -ballDY;
    ballY = height - ballSize / 2;
  }
 
  // update user position
  userPos = mouseY;
  if (userPos  height - paddleWidth / 2)
    userPos = height - paddleWidth / 2;
 
  // update computer position
  float compDY = (ballY - compPos);
  if (compDY > 10)
    compDY = 10;
  compPos += compDY;
  if (compPos  height - paddleWidth / 2)
    compPos = height - paddleWidth / 2;
 
  // draw computer paddle
  rect(0, compPos - paddleWidth / 2, 10, paddleWidth);
  // draw user paddle
  rect(width - 10, userPos - paddleWidth / 2, 10, paddleWidth);
 
  // draw ball
  ellipse(ballX, ballY, ballSize, ballSize);
}
 
void mousePressed() {
  if (ballDX == 0 && ballDY == 0) {
    ballDX = 5;
    ballDY = 2;
  }
}

Placebo’s Project 0

by teecher @ 4:24 am

Hi, I’m Placebo Ersatzspieler, a bogus student! Here’s my attempt to upload a PDF for Project 0:

GDE Error: Unable to load profile settings
« Previous Page
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