Welcome to Code Couch

Dan’s page

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

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

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

2010 1kB JavaScript competition

An homage to the 8-bit Atari version of BoingAugust 2010

Peter van der Zee ran a competition to see what can be achieved in 1kB of JavaScript code (that limit includes all whitespace).

For some reason I felt like recreating the Boing demo from my 8-bit Atari days. It came in at 1012 bytes, but I added a few line breaks for clarity (!), so in total it's 1020 bytes.

Miscellaneous graphics demos

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

London 2012 Olympics - rings demoMid 2008

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.

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 colourJune 2005

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.

Visit the June 2005 competition thread at the OZONE Asylum

AsteroidsMay 2005

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!

Visit the May 2005 competition thread at the OZONE Asylum

Roman clock 1March 2005

The goal: To make a Roman clock / watch.

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

Visit the March 2005 competition thread at the OZONE Asylum

Roman clock 2March 2005

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!

Visit the March 2005 competition thread at the OZONE Asylum

AquariumFebruary 2005

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.

Visit the February 2005 competition thread at the OZONE Asylum

Griffon airlines route plannerOctober 2004

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.

Visit the October 2004 competition thread at the OZONE Asylum

Body sliding on a surfaceSeptember 2004

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

Visit the September 2004 competition thread at the OZONE Asylum