Categories
Uncategorised

Phaser Development: Tank Wars

This week I have been working on adding some extra features to a tank game that I was tasked to make. I feel like i’ve been talking about Phaser on this blog but not really showing much of my own, so this week aims to fix that.

The first feature I added was a new type of tank I called the Hyper Tank which would act as a very powerful tank, so first I recoloured the tank assets so that I could visually tell the tanks apart and made the canon wider to give it a more powerful look, I think the atlas came out well.

The Hyper Tank sprite atlas

Next was making a class for this tank. It was a fairly straightforward implementation due to the existance of other classes I could extend and simply change a few variables. Looking back I did make the tank far too powerful but it gave me a bit of a laugh so I decided to keep it.

The class for my Hyper Tank. Short code, deadly power.

After that it was simply a couple extra checks in the scene to check for the spawn point and it was in the game ready to decimate, and oh boy did it do some damage…

I don’t think I can outrun this. Game Over.

My second addition was another level, so first thing on the list was to make it in Tiled. Nothing too interesting here, just randomised the ground tiles and set up a different configuration of wall tiles and then dot around some eney spawn points.

Nothing revolutionary, but gets the job done.

Next I decided to make a base scene class to make the actual scene classes a lot more compact, this was a proceess of figuring what functions and lines would be shared between the scenes. The update function did start to mess up a bit after this so I returned it into the actual scene which fixed the issues

A preview of the BaseScene class

With this done, I could make a very consice second scene which looked like this:

With all this in place, all that was left was to make it appear in game. So I wrote an if statment to check if all the tanks were dead, sadly I had issues with this part of the code, but the second scene still loads in fine, so i’ll have to check that out after this post.

Overall this project was pretty fun and it proved to me how useful classes can be for adding new things like levels and eneimes to a game. Some parts were tricky like adding the small parts across multiple files for multiple scenes to work but the overall amount of code is lower than I thought it would have been.