rtay.io/blog/post

Switch to dark mode

Planet Tanks

Had an idea for a quick game to toss up this week. Tanks, but on a spherical planet. This means you will be able to shoot around the planet, and possibly even shoot yourself. It seems pretty gimmicky, but won’t take too long to make so it shouldn’t interfere with the Project2 roguelike.

a grey planet a basic planetoid

I’m using a basic midpoint offset algorithm to generate the terrain, and then using some trig and primitives to make it into a planetoid shape.

From here I began to implement the tanks.

For the simplicity of collisions, I’m treating everything as if the game is flat, and then just drawing it in the relevant position around the circle. To do the wrapping, I simply ‘teleport’ the tank to the other side of the flat representation of the world, so it appears as if they’re seamlessly orbiting the planet.

The code looks something like this:

if (x < 0) {
    x += level_width;
} else if (x > level_width) {
    x -= level_width;
}

I set the tank’s y-coordinate to the current height of the planet underneath it.

a grey planet with 4 tanks around it some “tanks” added around the planet

And with the tanks rotated to the correct normals, it’s starting to look fairly decent.

another grey planet with 4 tanks around it

That’s all I’ve got for tonight. I’ll continue to work on this and keep you guys updated over the next few days. I’m also fairly busy trying to get some database stuff to work with the site, and also fixing that front page, so I can’t guarantee the tank game will have priority. I will try to keep working on it though.

And because I feel like it, a tiny little moon:

4 tanks on a small moon


A post by @rtaylz