🌈 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

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! 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?
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!
I learned to solve a Rubik's cube and it was incredibly disappointing - I tried to learn the Rubik’s cube and got bored of rote algorithms, which nudged me toward a GPS-to-map analogy that mirrors the junior-to-senior engineer journey: from following instructions, to pattern matching, to real understanding. Coding agents crush the first two levels, but they still lack taste and judgment—the difference between code that works and code that works well. I may never be a speed cuber, but with agents, I might just become a speed coder.
Vibing a PCB - surprisingly good - In my latest adventure, I challenged AI to design a working ESP32-S3 development board from scratch using Atopile and Claude. The idea was as simple as vibe-coding actual hardware without diving into the code. It was a chaotic yet fascinating journey, with some misses like unwired components and a forgotten capacitor. After a few prompts, the AI delivered a surprisingly functional board featuring USB-C, an AMS1117 regulator, and status LEDs. While not yet perfect, vibe-coding feels like a glimpse into the future of hardware design.
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