🌈 ESP32-S3 Rainbow: ZX Spectrum Emulator Board! Get it on Crowd Supply →
View All Posts
read
Want to keep up to date with the latest posts and videos? Subscribe to the newsletter
HELP SUPPORT MY WORK: If you're feeling flush then please stop by Patreon Or you can make a one off donation via ko-fi

Back in 2010 I wrote a tank game. It started life as a competition entry to win a laptop from HP by writing something for the Palm Pre (remember those?), got ported to the iPhone and iPad, and ended up on the App Store as Tanks! Mayhem, a Battlezone-style shooter with glowing vector graphics. It didn’t fly off the shelves; even back then competition was stiff in the app world. But it didn’t do badly.

Then in 2011 I got an email from Apple: Atari had complained that a game where you drive a tank around shooting other tanks infringed their copyright. I briefly thought about fighting this, but when your opposition is a company with lawyers on the payroll, it’s just not worth it. I pulled it from the US store, and that was that. I was pretty grumpy about it at the time.

Eventually, I moved on from writing my own apps and the source code has been sitting in a Dropbox folder ever since.

Sixteen years is a long time and things have moved on around it. It no longer compiles and there’s little point in submitting it to an even more crowded app store. It’s 20,000 lines of C++ and Objective-C, OpenGL ES renderers for three platforms, Blender models, sound effects: it’s a lot of code.

So, this week I pointed Claude Code at that folder and asked it to get the game running on the web. 20-30 minutes later:

Tanks! Mayhem running in the browser

Play it now at tanks.atomic14.com. Q/A and P/L drive the left and right tracks like the original Mac version, or just use the arrow keys. Space fires. It works on phones too (the original virtual joystick came along for the ride), and if you plug in a gamepad, the two analog sticks map onto the two tracks, which is how a Battlezone-style tank was always meant to be driven.

And here’s the 2010 original for comparison:

The original iPhone version from 2010

How the port worked

I was expecting to get some facsimili to my original game. Maybe a rough clone of Battlezone. Or, a completely broken version of my 16 year old code that barely worked.

Instead, Claude launched a bunch of angents to investigate the code - the renderer, the game logic, the input handling, the enemy tank “AI” etc.. And then it got on with writing the code.

The port over is pretty faithful. The physics runs on planck.js (a JavaScript port of Box2D) with the same damping, restitution and impulse constants as the iPhone version. The models are the original .obj files. The sounds are the original WAVs. It’s an exact port. Pretty impressive!

Recreating the glowing lines

The part about the game that I was really happy about when I wrote it was the nice neon glow effect. I had completely forgotten how it worked but I did remember that I’d done something clever with shaders and linewidths. The models are drawn twice. The dark, nearly-black solid faces go down first (so wireframes occlude properly, with a polygon offset pushing them back), then the edges go on top as 8-pixel-wide GL lines with additive blending. The line fragment shader computes each pixel’s distance from the line’s centre and fades the colour channels. The centre of the line saturates to white-hot, the fringes stay coloured.

Claude rewrote that by expanding each line into a quad. I can’t tell the difference.

Enemy tank exploding into line fragments

Weird bugs in my original code

The initial run that it tested for itself using the Chrome plugin didn’t work - it was just a huge drak polyhedron filling the screen. This turned out to be the player’s tank. Viewed from the indside.

This is Claude’s explanation…

My old esRotate function builds a left-handed rotation matrix, and the renderer negates the angle before calling it, so the two wrongs net out to a standard right-handed rotation. The port negated the angle and used a proper rotation matrix, which left a single wrong with nothing to cancel it: every model in the game faced backwards, and the first-person camera stared straight into the back of its own turret. That’s the trouble with old code: the bugs come in pairs that cancel each other out, and fixing just one of them breaks everything.

Some code that shipped 16 years later

My favourite discovery: the source contains a complete, working procedural radar shader (concentric range rings, crosshair, glowing blips, all computed in the fragment shader) that was compiled by the original game and then never called. The shipped game drew the radar with a texture instead. I have no memory of writing it or why I abandoned it.

It’s in the web version now. If you look at the radar at the bottom of the screen, you’re looking at a shader getting its first production deployment sixteen years after it was written.

The main menu, demo tank slowly orbiting

What didn’t make it

The multiplayer is gone: it was a LAN-only affair built on enet and Bonjour discovery, it worked back in 2010 really well but hard to recreate without some backend infrastructure. And the attack helicopter is gone too, though not for technical reasons: it’s fully ported and works, it’s just disabled behind a flag in the code, because absolutely nobody who played the original liked it. Game design feedback, finally addressed, a mere decade and a half later.

The code is on GitHub at atomic14/tanks-web: plain JavaScript and WebGL, no build step, every original constant preserved and commented with where it came from.

And this time it’s free, so hopefully nobody minds.

Related Posts

Invaders! is back: rescued from a forgotten Bitbucket account - I dug up my other 2009 iPhone game, Invaders!, after thinking the source was lost—turns out it was hiding in a forgotten Bitbucket git repo (thankfully not Mercurial). Claude Code helped port it to plain JavaScript and canvas while keeping the original OpenGL coordinate logic intact, so it plays exactly like the 2009 version—nixie tubes, bubble shields, UFOs and all. I fixed a 17-year-old power-up bug and worked around a bitmap font that can’t do a dash; you can play it now and browse the code on GitHub.
Creating an OpenGL game for both the Palm and iOS - I've made a triumphant return to the blogosphere with the release of my new game, 'Tanks!' developed for Palm Pre/Pixie and soon for iPhone devices. The game, an experiment to learn OpenGLES 2.0, is a testament to the feasibility of porting C++ or C code from iOS to Palm PDK, despite minor challenges with UI interaction and audio. So gear up, folks! Download 'Tanks!', step onto the battlefield and let the mayhem begin! Next stop on my coding odyssey - Android!
Tanks! Mayhem - available for the iPhone/iPad - We are excited to announce that our newly developed game, Tanks! Mayhem, is now available for download on iPhone, iPod touch, and iPad platforms. This action-packed game offers an exciting outlet for you to enjoy at a minimal cost of $0.99. Don't miss out on the mayhem!
Tanks! Mayhem - available for the iPhone/iPad - Exciting news gamers! Our new app, 'Tanks! Mayhem', has finally hit the app store. We can't wait for you to dive into the tank-battle action and enjoy all the mayhem it has to offer! For a sneak peek, take a look at some of our epic game screenshots included herein.
Tanks! will soon be removed from the US app store - Well, it's game over for my creation, Tanks!, in the US app store. You won't believe this but Atari's claiming it treads too closely to their copyright. Kinda feels like they think they hold the exclusive rights to all tank-driving games. I'm not buying their claim one bit but, when the game's bringing in less than a buck a day, who can afford legal bills, right?

Related Videos

But does it run DOOM? ESP32 ZX Spectrum update - All right, it's time for an update on my ESP Rainbow, the ZX Spectrum emulator with stunning full-color silk screen printing. I've been testing the latest boards, and PCB Way did a fantastic job. The enhancements include upgraded firmware, a 128k ZX Spectrum emulator, and a new 2-watt speaker replacing the old 7-watt buzzer. You can enjoy great sound with PWM and even play 128k games like The Never Ending Story. I've also added a snapshot feature and ported my video player over. Hardware upgrades include new capacitors and a slick power control chip for seamless battery and USB mode switching. We're gearing up for a commercial release, hopefully by Christmas, so stay tuned. And yes, it does run Doom! [Laughter]
Laser Projected Asteroids: ESP32 Reinvents Classic Arcade Game! - Learn how to create a classic Arduino ESP32 Asteroids game with laser projection, including a tour of the system hardware and a look at its firmware and game engine. Watch a demonstration and comparison of fonts, as well as an overview of the audio output. Dive into the schematics and try out the game for yourself!
Surprisingly Simple! - “16-bit" Mini Handheld Arcade - In this video, I explore and dissect a 16-bit handheld gaming machine that hosts 160 Sega games. This interesting gadget priced at twenty dollars is surprisingly accurate to the original Sega console. After unboxing and testing the game Golden Axe, I opened it up to check out the internal components like the pcb, chips, battery pack and controls. Although it's not very hackable, as the functionality lies under an epoxy blob, this little machine was a treat to disassemble and reassemble, all while still keeping its functionality intact. With a dash of nostalgia and quality gaming in a handheld package, the machine is certainly an intriguing find.
Streaming Video and Audio over WiFi with the ESP32 - In this video, we dive into a hardware hack combining several components to create my version of the TinyTV, complete with a remote control, and video streaming over Wi-Fi. We challenge the speed of image display, using different libraries and tweaking performance for optimal results. We explore Motion JPEG or MJPEG to decode and draw images quickly, and even reach about 28 frames per second. We also catered audio using 8-bit PCM data at 16kHz, and deal with syncing both video and audio streams. Finally, we add some interactive elements allowing us to change channels and control volumes, with a classic static animation thrown in for good measure. There's a few hiccups along the way, but that's part of the fun, right?
AR Sudoku Solver in Your Browser: TensorFlow & Image Processing Magic - Discover how to recreate a Sudoku app using browser APIs and ecosystem advancements, and explore the image processing pipeline technique for extracting Sudoku puzzles and solving them.
HELP SUPPORT MY WORK: If you're feeling flush then please stop by Patreon Or you can make a one off donation via ko-fi
Want to keep up to date with the latest posts and videos? Subscribe to the newsletter
Blog Logo

Chris Greening


Published

> Image

atomic14

A collection of slightly mad projects, instructive/educational videos, and generally interesting stuff. Building projects around the Arduino and ESP32 platforms - we'll be exploring AI, Computer Vision, Audio, 3D Printing - it may get a bit eclectic...

View All Posts