MentalFS's blog

MentalFS's picture

How we handle(d) land

As you might know, Tank You started as a completely different game, which was mainly supposed to be yet another clone of Worms. There are still a couple of similarities, but since we switched from animals to tanks a lot has changed, making Tank You more unique (at least in our eyes).

When we started our Tank You ancestor, land was supposed to behave like known in Worms. That means, an explosion should cut out a circle of the land, creating a hole. We didn't exactly know how it was done in the original, but the best guess is that the whole level is a graphic with one color being left out to mark the free space. Actually we can be pretty sure, seeing that this is exactly the format Worms 1 used for custom levels on the Amiga.

So around a decade long, we always used this method of representing land/the level. Of course we had to cut the level to several smaller images. Back then, most graphic cards didn't allow images greater than the screen size. Later it was done just to increase performance. And after switching to Slick, we had to respect the texture sizes from OpenGL and used alpha values instead of a color key.

I would say this was one of the few structures from our code that remained the same all the time and determined how the game looked and felt. Well, it was, until we decided to try a physics engine.

Using a physics engine provided us many benefits: The whole logic of how a bullet flies, when an object has to stop moving after hitting the ground, collision detection and in what angle a tank has to be where it stands is taken over by the engine. But it also has its downsides. Basically everything has to be represented in a way the engine understands. That means, regarding the level: we can't just use an image. The engines we tested want their objects to be polygons.

Translating an image into polygons would either be inaccurate or just madness. We didn't even try that because it would take up more memory than the images themselves. Instead, we threw away our understanding of how land works in the game. Land is now divided into little polygons. This changes a lot: Explosions now can't just cut a hole in the ground. But wouldn't it be boring if the level was undestroyable?

We certainly think so. We decided to add Hitpoints to chunks of land. Land is now maybe not immediately destroyed, but if hit several times, or hard enough, it will be gone. It still looked a bit wrong because we were used to pixel accurate explosions, so it was a sacrifice.

But a little addition makes the new way land is handled brilliant: We can make the chunks movable. When the hitpoints are reduced below a certain treshold, a chunk of land will become loose and fly around. This brings a whole new kind of dynamicity to the game.

They can fall down, they can block the way of your tank. But they can also help you moving over a pit. Maybe some day they will crush you when they hit you, but that's not implemented yet. Until then you can shoot or try to push them out of your way.

Syndicate content