Here you'll find a collection of some of my code snippets. Some have a practical purpose, while some are for fun or demonstration purposes.

Please feel free to try out or use any of the snippets here. If you do use any of the code here, please acknowledge its origin as detailed on the terms of use & license page.

Over time, I'll be adding a more blog-like interface with categories and the ability to search.

Note: Most of the snippets require JavaScript to be enabled before they will run.

Miscellaneous graphics demos

These are some miscellaneous graphics demos that I've written.

London 2012 Olympics - rings demo

I wrote this to celebrate London being the host city for the Games of the XXX Olympiad in 2012.

It was originally based more on the code from 'A splash of colour', but greatly simplified when I removed the perspective projection.

Run London 2012 Olympics - rings demo

Twenty line JavaScript competition entries

Every month, the people in the DHTML/JavaScript forum at the OZONE Asylum hold a 20-line JavaScript competition. It's just a bit of fun, so the 20-line rule isn't strictly enforced. The prize is to set the challenge for the next competition. Here are some of my entries.

A splash of colour

The goal: To show a good working use of opacity.

I was quite pleased with the way this turned out. I originally used 120 bars, which ran fairly smoothly on my super-fast laptop, but reduced that to 30 after realising it crawled on any remotely slow computer.

Run A splash of colour

Visit the June 2005 competition thread at the OZONE Asylum

Asteroids

The goal: To make a game involving asteroids.

I personally think that I over-used the "substr()" trick to reduce the line count here… but don't let that spoil the game!

Run Asteroids

Visit the May 2005 competition thread at the OZONE Asylum

Roman clock 1

The goal: To make a Roman clock / watch

I really enjoyed creating the decimal to Roman numeral convertor. The "five-units" (5, 50, 500) really stumped me for a while, but I finally worked out how to deal with them.

Run Roman clock 1

Visit the March 2005 competition thread at the OZONE Asylum

Roman clock 2

The goal: To make a Roman clock / watch

For this version, I skipped the "proper" conversion routine in favour of one that took up fewer lines!

Run Roman clock 2

Visit the March 2005 competition thread at the OZONE Asylum

Aquarium

The goal: To make a zoo, whether it holds static or animated animals, or even a real zoo where you feed the animals.

I found the tank and fish graphics using a Google image search, cropped the fish to be transparent, and was amazed at the results.

Run Aquarium

Visit the February 2005 competition thread at the OZONE Asylum

Griffon airlines route planner

The goal: To make something that exhibits some sort of A.I. behaviour.

This utility was originally written for a Multi User Dungeon called Storms of Time. The MUD has an airline system run by Griffons (who also run the banking system). You pay your cash, climb onto their wings, and fly to another airport.

Run Griffon airlines route planner

Visit the October 2004 competition thread at the OZONE Asylum

Body sliding on a surface

The goal: To make something that has some sort of physics engine in it.

Run Body sliding on a surface

Visit the September 2004 competition thread at the OZONE Asylum