Tuesday, May 24, 2011

Reminiscing on XTux

Way back in 1999, I wrote a game (in C using raw X-Windows calls! source code) for Linux called XTux.
The graphics were made by my friend James Andrews (who recently started a blog on iPhone games)
Some interesting things I remember from the project:
-All data was in flat text. The maps kind of looked like ASCII art.
-You could write text strings onto the maps (see Slashdot level screenshot)
-Particle System (see railgun trail and blood splatter in screenshot). One of the most common forms of procedural graphics, now standard in most game engines - this was my 1st implementation and I got a lot of use out of the code (weapon effects, smoke, explosions, blood etc)
-Recording/playing demos was a nice hack: The client was very simple - read messages about what to draw from the server. By taking advantage of the polymorphism in Unix file descriptors, the source could be either a socket connected to the server, or a stored local file of previous gameplay.
-Generating different images (eg preview mini maps) from displaying the same map data in different ways.
-Because the levels were flat text, I was able to easily write a Perl script to generate levels, though I didn't take that beyond generating an arbitrary sized maps of grass with randomly placed trees.

Wednesday, April 6, 2011

WebGL - 3d in the browser

You may have noticed the software on this blog is written in javascript (HTML5 Canvas), with the goal being you don't have to download any software to view the demos.

The trade off is things run much slower than native code. But computers are really fast nowdays & and people's attention span and desire to install software is very low.

Finally there seems to a 3d web standard emerging, WebGL - a 3d version of the 2d canvas library I have been using, and so fits in the same niche described above. Click to find out "does your browser support WebGL?"

Some cool examples: http://www.chromeexperiments.com/webgl

A Tron Lightcycle game on 3d surface: http://cycleblob.com/

Thursday, August 26, 2010

Skies & Silhouettes

Click the image on the left to start the demo. Update: There appears to be a bug that shows up in Chrome, where the sky is really blocky, but it works fine in FireFox. I've got big plans for doing a project with heaps of skies and silhouettes (I'm kind of obsessed by them), and made this little program to quickly test out what different generated skies look like. I had fun playing with it, hope you do too. Try out some examples, change the color values and click the button. Update: (23/9/10) Added MaxAlpha setting, the actual alpha is a random number between 0 and this value, so the fact that you can set a number much higher than 255 is a feature not a bug.

Saturday, June 19, 2010

Flock in a cloudy blue sky

Click on the image to load the canvas demo (requires FireFox or non-IE browser) I took the existing Javascript boids implementation from Coderholic, and made it look pretty with swallows on a cloudy background. The birds follow the standard 3 rules for Boids as first implemented by Craig Reynolds Separation: steer to avoid crowding local flockmates Alignment: steer towards the average heading of local flockmates Cohesion: steer to move toward the average position of local flockmates These simple rules for each individual leads to the group behavior - there is no central group intelligence or control. Flocking behaviors like this are often described as being emergent. Update: (23/9/10) There is now an initial pause as the simulation runs 500 steps before displaying the boids. This removes the ugly initial craziness before they start flocking properly.

Thursday, June 17, 2010

LSystem 3

Click on the image below to load the canvas demo (requires FireFox or non-IE browswer)

 I added a zoom, and moved the Javascript into its own file. A tip is to zoom with a very low iteration, as otherwise it is very slow. I am going to look at rendering to a buffer and allowing scrolling.

Monday, June 7, 2010

Falling Leaves

Click on the image on the left to load the canvas demo (requires FireFox or non-IE browser). As with all of these demos, try clicking reload a few times to see different random versions. Just an idea I had while riding my bike home, looking at fallen leaves (it's the start of winter here) I changed the l-system renderer to use curves which I think makes the trees look more natural. I also used the canvas wrapper to be able to get the position of the leaves as they are generated so I can animate them. Update: (23/9/10) Added hack to make leaves appear to collect on the ground beneath the trees.

Tuesday, May 18, 2010

Cloudy blue Perlin sky


Click on the image to load the canvas demo (requires FireFox or non-IE browser) Perlin Noise is a technique for generating procedural textures, commonly used for smoke, clouds or to add a random looking realistic roughness to surfaces. The algorithm is basically to generate noise, then scale that noise randomly across an image at different sizes and levels of transparency. This creates a self similarity which mimics the appearance of some natural processes. I found a canvas implementation by iron_wallaby and made the noise be the transparency of pure white, giving a cloud like effect. This was originally going to be just the background for another canvas demo I was working on, but that is delayed as I'm currently doing bioinformatics study/working on a project in my spare time. Things to improve on this are restricting how cloudy it is to a range, and removing some visual artifacts (lines/blockiness)