We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexDiscussionExhibition › Architectris
Page Index Toggle Pages: 1
Architectris (Read 1120 times)
Architectris
Apr 8th, 2006, 3:18pm
 
This is a joint project between me and John Holder. You play a variation on Tetris by moving left and right in front of a video camera. The game tracks movement using a very simple tracking algorithm that runs a lot faster than using an overkill tracking library.
Code:

//white tracking function, scans source image for the greatest value of brightness in vertical columns
//the return value is the brightest column scanned
static int trackWhite(PImage source, int columns, int columnWidth, int speed){
int [] brightnessTotal = new int[columns];
for(int i = 0; i < columns; i++){
for(int j = 0; j < source.height; j++){
for(int k = 0; k < columnWidth; k += speed){
int pixel = (i * columnWidth) + k + j * source.width;
brightnessTotal[i] += grey(source.pixels[pixel]);
}
}
}
int brightest = -1;
int bright = -1;
for(int i = 0; i < columns; i++){
if(brightnessTotal[i] > brightest){
bright = i;
brightest = brightnessTotal[i];
}
}
return bright;
}

//integer brightness function for extra speed
static int grey(color p){
return max((p >> 16) & 0xFF, (p >> 8) & 0xFF, p & 0xFF);
}

The game also features a 3D font called quadText which has functions to render it and an object which generates wobbly quadText.

The unfinished project page is here and has a link to a source code archive.

Honourable mentions to Fry for the speedy brightness value function and JohnG whose work inspired the quadText function and classes.

If anyone has comments on how better to present the project page, if the code is hard to read or any general feedback, I invite you to respond to this post.
Re: Architectris
Reply #1 - Apr 13th, 2006, 1:31am
 
Woo! Online version up and running. Mouse and keys only though. Scroll down to view controls. 1024x768 resolution or larger required. OpenGL support (JohnG hack - credited on page with link to hack).

Updated info - including a link to my collaborator's site. Still need to get the wallpaper sorted though.

All done
Adding to exhibition - still the same link as above. Discovered I can use smooth() with OPENGL so I've updated the code. I'm going to leave the web page alone now (wallpapered with opaque divs in Mozilla), I've got a new video-responsive project to do.
Page Index Toggle Pages: 1