Inspiration

As a kid, there was a minigame that I loved that featured tanks battling it out. I wanted the minigame to have upgrades, more levels, bigger maps, and online multiplayer. I built it so that I could share the fun with my friends and show them a piece of my childhood.

What it does

It's an online game! You can play single player or multiplayer by clicking Multiplayer and then choosing your own game room code. Use WASD to move and point and click to shoot. Be careful - bullets will ricochet off the walls.

How I built it

It's a funny story - I actually was building a real time strategy game for a hackathon, which was way too much to try at once. It turns out that during the hackathon, I built the real time socket communication portion. Then afterwards, I decided to build this game as a way to test my socket library, "corridors" (available on npm but deprecated now).

I used Phaser.io (Phaser 1, I believe), and the rest is pure html, css, and javascript. The sockets were done with socket.io (this was before Websocket was a standard protocol) and the server is running node.js. I deployed to Heroku (hence the strange url).

Challenges I ran into

The multiplayer part was the most confusing - how do you sync up the players? The logic that I built for it was complex enough that I abstracted it into its own library and used my own library to complete this project.

There are more confusing bits that I had to work out:

  • rotating the body of the tank and the head separately
  • rotating the body (try moving and you'll see the tank doesn't move until the body is rotated to the correct direction) conditionally based on its proximity to the wanted direction
  • creating the map editor, laying out the grids, and coming up with ideas for enemy tanks etc.

Accomplishments that I'm proud of

I love seeing people play this game. It's retro - it makes me think of my childhood. And the multiplayer aspect is always a neat surprise.

I'm also proud of it because I built it all the way through, from scratch, and as a first attempt at an online game, it plays pretty well.

What I learned

Before I made Tanks, I had only ever made Flash games. This was my first attempt at a non-flash web game, and I have to say, it was amazing! It runs faster and doesn't depend on the Flash runtime. I also learned that intelligent AI can be hard-coded, it's okay. The AI in this game is pretty hard-coded and yet the enemies still seem pretty smart.

What's next for Tanks!

Someday I'll go back and update this game. I've learned a lot about software engineering since I built it, and I think I can make it even better. It also has some hilarious bugs and cheats available, so I might have to fix those. Well, some of them :)

Share this project:

Updates