top of page

Tanks!

game.png

Tanks! is a two-player local multiplayer game set in the desert. The game is played on one keyboard, with each player taking half of the keyboard. The player on the left of the keyboard moves with the WASD keys and fires their cannon with the space bar. The player on the right side of the keyboard moves with the arrow keys and fires their cannon with the enter key. The goal of the game is to hit the other player with your cannon. The distance the cannon fires is based on the period of time with which the cannon button is held. The health bar for each player is a small circle surrounding their tanks which changes progressively from green to red as the players health decreases. When one of the player loses all of their health, the other player receives a point and the round is reset. The first player to five points wins!

GameManagerRoundStartingScript.png
GameManagerRoundPlayingScript.png
GameManagerRoundEndingScript.png

These code snippets come from the GameManager script which controls each of the rounds and the overall game. There are separate methods for when the round starts, during the round, and when the round finishes, In round starting, all the tanks are reset, their control is disabled, and the round number is updated. In round playing, the tanks control is enabled, and a while loop checks for one of the tanks to die. In round ending, the tanks control is again disabled, the round winner is set and the scores are updated. Additionally, the damage due to each cannon hit is calculated in this script, based on the distance between the cannon explosion and the tank.

GameManagerCalculateDamageScript.png
TankShootingInspector.png
TankMovementInspector.png

The images show the requirements in the inspector for each of these scripts which are responsible for the movement, health and shooting of the tank as well as the explosion of the shell.

TankHealthInspector.png
ShellExplosionInspector.png

The image to the right shows the model of the shell that was created in 3DS Max to be used as the shell in the game. The color of the shell in the game was changed to gold.

Shell3DS.png
HealthBarPhotoshop.png

The image to the right is the Photoshop image of the health wheel that is used for the player. The image below is the code snippet which updates the wheel when the player's health needs to be updated.

SetHealthScript.png

These code snippets to the right show the code used to make the player turn and move in the TankMovement script.

MoveScript.png
TurnScript.png
OnEnableHealthScript.png

These code snippets to the left shows the functions run when the tank is initially instantiated, and the updates made to the tank after every frame.

UpdateScript.png

These code snippets to the right show first the TakeDamage function, which when called will update the player's health. If the player's health is less than or equal to zero, the OnDeath function is called. This function makes the tank inactive and creates an explosion.

TakeDamageScript.png
OnDeathScript.png
AwakeScript.png

This code snippet to the left shows the initial conditions for the shell explosion script before a shell is fired.

This code snippet to the right shows what happens when one of the shells collides with a tank. Damage is dealt to the tank, the tanks health is updated, an explosion is created, and the shell is destroyed.

ShellExplosionOnTriggerEnterScript.png
FireScript.png
UpdateTankShootingScript.png

These codes snippets to the left show the Fire and Update functions from the Tank Shooting script. In the fire function, an instance of a shell is created, and a launch force is applied. In Update, it is checked if the player is attempting to fire a shell, and all the necessary updates are made for the shell.

bottom of page