« Introduction to video games | Main | CTIN 405 - Sketch 1 »

CTIN 544 - First Processing sketch

processing1.png

As I incorporated the video camera, I can't post the exported sketch, but here is the code for my first assignment:

import processing.video.*;

Capture cam;

int xPos = 140;
int yPos = 480;
float percent = 0;

void setup()
{
size(760,480);
background(0);
smooth();
cam = new Capture(this, 320,240);
}

void draw()
{
//background(0);
fill(random(254));
noStroke();
ellipse(xPos,yPos,90,90);

float time = millis();
percent = (time % 10000)/10000;

xPos = int(800*percent);
float pos = abs(380-xPos);
int yLength = int(sqrt(sq(400) + sq(pos)));
yPos = yLength - 100;
fill(255);
ellipse(xPos,yPos,90,90);

stroke(random(200));
int sticks = int(50 * abs(0.5 - percent));
println("STICKS" + sticks);
for(int i=0;i<=sticks;i++)
{
stroke(random(200));
int lineX = int(random(760));
line(lineX, 480, lineX, 0);
}
for(int i=0;i<=18;i++)
{
stroke(0);
strokeWeight(random(5));
int lineX = int(random(760));
line(lineX, 480, lineX, 0);
}

if (cam.available() == true)
{
cam.read();
blend(cam,0,0,160,100,0,0,760,480,OVERLAY);
}
}


Post a comment

About

This page contains a single entry from the blog posted on January 22, 2009 10:43 PM.

The previous post in this blog was Introduction to video games.

The next post in this blog is CTIN 405 - Sketch 1.

Many more can be found on the main index page or by looking through the archives.

Powered by
Movable Type 3.31