Jon Combe logo

Thrust: recreating a classic 8-bit game in JavaScript

April 201013 years, 10 months ago

tl;dr: Just take me to the game!

I must have been seven or eight years old when my Dad bought a BBC B Micro for my brother and me. It may have only come with 32k of memory and an 8-colour display, but it was easily the greatest non-human influence on my life.

BBC B Micro

Like most kids, we initially used it to play games, but it wasn't long before I was teaching myself how to code simple programs. Decades later, not much has changed.

I would never be described as a gamer. There have only been three titles that truly got me hooked: the visionary Elite (BBC B), the football gem Kick Off 2 (Amiga) and last, but by no means least, the amazing Thrust (BBC B).

Thrust was awesome but incredibly difficult. Tears of frustration were shed playing it as a kid. You can see YouTube videos of the original gameplay (part 1) and (part 2).

Piloting a spacecraft through a two-dimensional world, the aim is to destroy a reactor, pick up a pod using a tractor beam and escape with it into outer space. Add enemies shooting at you, flying through caves, (reversible!) gravity, and a lot of physics (the pod is heavy), and you find yourself in a game much more tricky than it first looks.

Thrust on the BBC Micro

Coding this was a real challenge; there were no game or physics frameworks to help out back then, so what you see here is hand-coded vanilla JavaScript drawing dots and lines in a <canvas> tag in a continuous loop. My version isn't perfect but I'm proud of how playable and close to the original and it is.

Before I give myself a pat on the back, think of the original author, writing this in 1986 on the original machine with just 16k of memory. No build tools. No debugger. Maybe a reference book or two. StackOverflow? We don't know how lucky we are.

I enjoyed 5 minutes of fame when this page was featured on Google's Chrome Experiments website back in the day.

The 2010 version of my game used a Flash plugin to play the game sounds (it was effectively the only option at the time). When Flash disappeared from our browsers a few years later, my game stopped working. Feeling the itch to play again in 2023, I finally got around to swapping out the Flash sound player for native browser audio.

The code is otherwise untouched from 2010 and available on GitHub. Looking back on this code years later, I cringe inside, but I'm proud of how good this was and how far I have come since. My days of using Hungarian notation for variable names are long, long gone. Thankfully JavaScript and I have also grown up a lot since then.

Enough talk. Ready? Play Thrust!

Sorry! Thrust needs a bigger screen to run.
Open this up on your desktop or laptop to play the game.
It's worth it :)

Some people complained they found the keys confusing. They are same as the original game:

Rotate anti-clockwise
Rotate clockwise
Shield / tractor beam
Pause / un-pause
Quit game

You can also configure the game a little before playing:

Choose your own keys
Enter cheat mode

Press the space bar to start. Happy flying!