Sunday, November 15, 2009

Twenty Years of Mastery

This has nothing to do with video games, but since I'm one of those fans who remembers how he played a delightful flick off the backfoot through midwicket off Waqar Younis to reach 4000 runs in ODIs, I needed to say something



Cricinfo's Surfer has a roundup of all the tributes.

And as a token nod to videogames, it seems the man is a champ at Snake

Monday, June 15, 2009

Fast Fourier Transform in Actionscript

As part of the beat detection required for The Rhythm Game With No Name, I had to put together an FFT function that could be used on any portion of the song. Flash does have a function to do this but AFAIK it can only work on the portion of the song that is playing. Anyways here's a function that can be used on any array of floats



   private function FFT(dir:Number, m:Number, x:Array, y:Array):void

{
//trace('Getting FFT');
var n:Number; var i:Number; var i1:Number;
var j:Number; var k:Number; var i2:Number;
var l:Number; var l1:Number; var l2:Number;

var c1:Number; var c2:Number; var tx:Number; var ty:Number; var t1:Number;
var t2:Number; var u1:Number; var u2:Number; var z:Number;

n = 1;
for (i=0;i<m;i++)
n *= 2;
// n = m;

/* Do the bit reversal */
//trace("Bit Reversal");
i2 = n >> 1;
j = 0;
for (i=0;i<n-1;i++) {
if (i < j) {
tx = x[i];
ty = y[i];
x[i] = x[j];
y[i] = y[j];
x[j] = tx;
y[j] = ty;
}
k = i2;
while (k <= j) {
j -= k;
k >>= 1;
}
j += k;
}



/* Compute the FFT */
c1 = -1.0;
c2 = 0.0;
l2 = 1;
for (l = 0; l < m; l++) {
// trace('FFTing at ' + l + ' of ' + m);
l1 = l2;
l2 <<= 1;
u1 = 1.0;
u2 = 0.0;
for (j=0;j<l1;j++) {
for (i=j;i<n;i+=l2) {
i1 = i + l1;
t1 = u1 * x[i1] - u2 * y[i1];
t2 = u1 * y[i1] + u2 * x[i1];
x[i1] = x[i] - t1;
y[i1] = y[i] - t2;
x[i] += t1;
y[i] += t2;
}
z = u1 * c1 - u2 * c2;
u2 = u1 * c2 + u2 * c1;
u1 = z;
}
c2 = Math.sqrt((1.0 - c1) * 0.5);
if (dir == 1)
c2 = -c2;
c1 = Math.sqrt((1.0 + c1) * 0.5);
}

/* Scaling for forward transform */
if (dir == 1) {
for (i=0;i<n;i++) {
x[i] /= n;
y[i] /= n;
}
}
}




And here is how you use it. First we load extract the song into a ByteArray. Then we read in 1024 samples from the ByteArray (using readFloat) and call the FFT function on those arrays. To perform the FFT on a different portion of the song, simply set the read position of the ByteArray accordingly.




s = new Sound(soundToLoad);
var extractLength:Number = Math.floor ((s.length * 88.2));
s.extract(bytes, extractLength);


fftx = new Array(1024);
ffty = new Array(1024);

for (j = 0; j < 1024; j++)
{
if (bytes.bytesAvailable)
{
fftx[j] = bytes.readFloat();
ffty[j] = bytes.readFloat();
}
}

FFT(1,10,fftx,ffty)


Labels: , , , ,

Friday, June 05, 2009

The Rhythm Game With No Name

The title does not refer to this abomination but to a new game I've embarked upon. I recently played Bit Trip Beat and the game is so bloody brilliant that it has forced me to try my hand at making a game where the levels get generated based on any mp3 you throw at it (a la Audiosurf). The general idea for now is to have a bunch of minigames that get presented to the player in a rapid sequence.

There seems to be a wealth of literature out and the thing I first did was implement the ideas suggested here

Thankfully, with the release of Flash Player 10, Adobe lets you get at the bits in a song (earlier versions only let you access spectrum information for the particular slice that was playing).

Initial thoughts on the gamedev article: It worked brilliantly for "I Turn My Camera On" (by Spoon) and not so good for messier songs (Head like a hole). Its highly unlikely that the output from these is going to be as good as the hand-coded patters you see in Guitar hero/rock band.

Labels: ,

Sunday, February 08, 2009

The Adventures of Jonas and Johan



I managed to attend the 1st ever global game jam at the Detroit center. The theme was "As long as we're together, we'll never run out of problems". The other constraint was that the game should last no more than 5 minutes. The game I came up with is "The Adventures of Jonas and Johan" (thanks to Clarence Rice for the artwork). You can play it here or here. It is undertweaked and underpolished but something promising lies underneath.I spent a bit of time learning how to use the Box2D engine and plan to spend some more time fiddling around with it.

Thursday, January 15, 2009

Global Game Jam

There's a global game jam happening on the 30th of January. Ad-hoc teams at various locations across the globe will try and come up with something playable within a span of 48 hours. Game Jams in the past have resulted in some buzz-generating games like Rara Racer (which I liked) and Passage (which, to me is a work that has received far too much attention), so it'll be interesting to see what comes of this.

I'll probably be going to the Detroit center. Am quite looking forward to it.

Friday, January 09, 2009

Currently Playing : The Manipulator



Take control/Manipulate an enemy, make him kill everyone else, jump to the exit. That seems to be the gist of what you have to do in this game. It is very well presented. There doesn't seem to be a save-game option which is what made me stop playing. That, and the fact that 4 levels into the game there doesn't seem to be much use of the 'manipulate' mechanic. The platforming controls are also a bit out of tune.

Labels: ,

Thursday, November 13, 2008

Currently Playing : This is Africa a.k.a Far Cry 2


Instead of writing about the gorgeous locales and graphics, or the sandbox design I just thought I'd post an entry from Qurbani Singh - The turbanator (since he resembles another patka-wearing assassin) journal.

-----


I had one mission where I'm supposed to destroy a truck that is bringing in arms supplies to the city. So go to my safe-house, set the timer to sometime around 10 pm so I can move around in the dark (and intermittently look at the spectacular moon). I wake up, hop into my vehicle. On the way I lay waste to one of the guard posts. The next guard post is across a bridge, and they spot me while I approach and open fire. My vehicle is trashed, and as I try to evade them I fall onto a ledge jutting out of a cliff, with no apparent way of getting back up to higher ground. I look down at the river flowing beneath me. Seeing no other option I dive, survive the fall, and swim to the shore. Another guard post lies somewhere ahead on the river bank. I slowly move through the grass, sneak up behind one of the guards, kill him with my machete, run, grab the boat and set off towards the area where the arms-truck is expected to arrive.

So I'm tracking the truck as its moving along its route, and about a mile away I hide behind a rock, pull out my rocket launcher. As the arms-truck approaches, I jump out fire the rocket and blast it, it flies upwards. I'm just admiring the wreckage, tires bobbling around, the nearby grass is on fire, the driver and armed guards are dead, and there's a nice message on the screen saying "Objective completed".

Then I look up, the truck is falling down, heading right towards me. Too late. I'm crushed beneath it and die.

What a game!

Labels: , ,