top of page

 

Tiny Tanks was a Project I made for Programming and Mathematics for games. Within this project I created my own math library which included many equation definitions for vectors and matrices in 2D, 3D and 4D. These equations and functions were used to develop the functions for tank movement and calculations of the bullet trajectory.

Features Include:

- Class Inheritence

- Collision Detection

- Coordinate Systems and Vectors

- Vector Projectile

- Math Library with Equations

- Matrix Inversion and transformation

- PowerUps

- Map Generation

- Reading from a file

When the current state equals the menu, the program will constantly retrieve the mouse position during every frame. The pink hexagons represent if statements that hold the boundaries of each button. If the mouse position is within one of these boundaries it will proceed with the following code. For example: If the mouse position (x, y) is between 476, 286 and 632,307 then the program will set the UV sprite coordinates to the corresponding picture to allow the player to see that they are hovering over the controls button in the menu. This is done by an arrow pointing to the corresponding button. The next pink hexagon, following the purple box that sets the UV sprite coordinates, is an if statement. This if statement finds out if the button has been clicked. If the button is clicked it will proceed down the green arrow. This will change the current state to controls and change the UV coordinates. If it is not clicked, the program follows the red arrow which has no response, so the code repeats again. This will repeat until the user has clicked the play button, starting game play, or clicked quit which clears the screen and continues down to the end of the code.

For the Powerups during game play a few if statements loop each other. The powerups spawn (appear so they can be collected) around every 15 seconds. This is what the first if state is looking for. It also checks to see if there are any powerups currently on the screen, to prevent more than one powerup at one time, allowing the player to cheat. If 15 seconds has passed and no powerups are currently active the program will calculate a random number between 1 and 2. This number will determine which powerup will spawn (appear) in the map, as there are 2 different powerups to choose from. The program will then proceed with another if statement dependant on the random number outcome. If the random number equals zero, the powerup will be a mine. Therefore, the code will initialise the mine by creating and drawing the sprite (picture of the mine). It will then state that it is active as it is currently shown in the map. However, if the random number was 1, it will do the same but instead draw and create a sand timer instead of a mine, producing a different powerup. Once a powerup has been created the program will check if the player has collided with it when the powerup is active (shown in the map). This will occur every frame to constantly keep the program updated on whether it has collided or not. Once the player has collided it will proceed with the code within the “powerUp" class.  This will then put into action the effects of the powerup.

Tiny Tanks

bottom of page