A Boulder Dash Clone in Only 20 Lines of JavaScript

This was my very first entry for the quasi-regular, friendly 20-line JavaScript competition over at OZONE Asylum, for the month of January 2008. My entry titled “Rockford the Invincible” got the second place among some very impressive entries (I was actually a bit shocked that I got the second place).

Rockford the Invincible

In-game screenshot. Click to play!

The winning entries were:

  1. Candle Flame by Arthurio
  2. Rockford the Invincible by me
  3. Castle Wolfenstein by Mathieu “p01” Henri

And here’s the explanation of how I managed to get placed above p01’s entry. Quoting Wrayal, that month’s topic setter and therefore judge:

[On Castle Wolfenstein] Ok…maybe this one needs a little justification. A lot of people may have expected this to win. It was a fantastic script, don’t get me wrong! (“stop it! You are doing impossible things! What if reality find out?!” ;)) In particular, I thought the map showed exactly the sort of flair that would normally win. But we know you’re capable of this ;) you’ve set yourself too high a standard :P What can I say, it was a great script, but I’d be interested to see what else could be implemented - I liked the rockford entry for example for the many simultaneous actions.

For those unfamiliar with the title, Boulder Dash is a classic game from the 80’s. I used to play it a lot on my Atari 800XL when I was a kid. Since being hooked on programming, writing Boulder Dash clones (or derivatives) has become a habitual thing that I do when I get my hands on a new programming language. A friend (who incidentally is the author of BoulderCat) recently joked about this habit being my version of “Hello, world!”.

Since I had to fit everything in 20 effective lines of JavaScript, this of course is not a complete implementation of Boulder Dash. For instance, Rockford, the main character, never dies. You can freely move around the monsters and stop falling boulders with your head. I’ve therefore called the game “Rockford the Invincible”. Just “Boulder Dash” would have been too obvious.