Tank Game – Production Process

You can find my version of the game here

To add a twist to the tank base game we were given, I decided to add in a super bullet attack for the player and land mines. The super attack was available on the Q key, and it was an instant kill if it hit an enemy; however, the player could only use this attack up to 3 times before they ran out of super bullets. The land mines would deal 1 point of damage to an enemy and were randomly placed through the level.

To create the super bullet, I needed to make a new physics group, with a maxSize of 3, to prevent the player from using it an unlimited amount of times. I adapted the existing try_shoot function to create a try_shoot_special function. My reason for creating a separate function rather than extending the existing one was that I needed to get a bullet object from a different group, it needed to handle damage differently and there needed to be a counter for each super bullet fired.

function fire_special(bullet, rotation, target) {
    bullet.body.collideWorldBounds = true;
    bullet.body.onWorldBounds = true;
    bullet.rotation = rotation;
    this.physics.velocityFromRotation(bullet.rotation, 500, bullet.body.velocity);
    var destruct_layer = this.map.getLayer("destructibles").tilemapLayer;
    this.physics.add.collider(bullet, destruct_layer, damage_wall, null, this);
    for (var i = 0; i < enemy_tanks.length; i++) {
        this.physics.add.overlap(enemy_tanks[i].hull, bullet, special_hit, null, this);

As the special bullet was incapable of hitting the player (as only the player could fire them) I didn’t need to detect who was firing the bullet, I only needed to cycle through all the enemy tanks. Furthermore, when a tank was hit by the bullet, I didn’t need to call damage tank, instead I skipped that step and moved straight to destroying the tank.

function special_hit(hull, bullet) {
    enemy.damage_count = enemy.damage_max;
    var explosion = explosions.get(hull.x, hull.y);
    if (explosion) {
        explosion.on("animationcomplete", anim_complete, this);
    if (enemy.is_destroyed()) {
        enemy_tanks.splice(index, 1);

I still called the is_destroyed() method of the enemy, to act as a safety buffer in-case an error had occurred elsewhere in the code that caused the tank to still be alive.

While implementing the land mines, I had to shrink the image size, as despite being pixel art, it was massive and filled the screen. I used some trial and error to calculate how much I had to reduce the landmine’s size by, but in the end I was happy with the result. I wanted the landmines to be randomly placed around the screen, so I used the Phaser.Math.RND function to scatter them as best as possible.

for (var i = 0; i < land_mines.maxSize; i++) {
        var land_mine = land_mines.get(Phaser.Math.RND.integerInRange(game.config.width * 0.01, game.config.width), Phaser.Math.RND.integerInRange(game.config.height * 0.01, game.config.height));

My main criticism with the landmines now is that they can spawn on top of walls. If I had created a collision between the landmines and the destructible walls, this would have resolved the problem, and created a unique feel to each play of the game by changing the landscape slightly every time. Another spawn problem I had was that enemy tanks all spawn in the initial game area, making the rest of the level map feel empty and boring, I could resolve this using objects in tiled, and spawning tanks at those locations, but this would mean the tanks positions were fixed, and would remove an element of randomness from the game.

If I was to continue to work on this game slice, I would add in the ability for the landmines to blow up walls to prevent the overlapped spawning. Also, I have the issue of tanks still being able to shoot even after they are damaged to the point that their turrets were blown off. I feel it would add more realism to the game if the enemies were incapable of shooting at this point. Finally, I would make it easier for the player to tell how many super bullets they have left, as they currently just have to remember.