This tank game was a month long project produced by a four person team in an algorithms course. It was to be developed alongside our lessons
as hands on work utilizing various algorithms learned in class. It was developed through turtle graphics with python. It aided as a wonderful opportunity
to get experience working on a project with a runtime and real time interactivity. As with any game, it is ran through a main loop with various functions to
perform the different instances in the game. This ranged from rendering the tanks, ai movement, collision detection, projectile shooting, and distance
calculations.
As seen below, the design is relatively simplistic as the main focus was what aspects of programming make a game work rather than the appearance of the game.
The base requirements were having the main player tank with enemy tanks that target the user. There should be a pause button that triggers a grid screen
which can be resized. When clicking on a cell on the grid, the user can dynamically create obstacles which the enemies must work around to reach the user. The real time distance
and health of each enemy is shown, reducing whenever the enemy gets closer or takes damage.
There are a few algorithms that are important for general functionality. As with any game, there is a constant runtime loop which performs each algorithm.
The highlight is the math involved with every concept. The user is starting at an x and y axis, and for movement there is a function involved with changing the
x or y axis of the player. Collissions occur when the loop constantly checks the users position in relation to the collision boundaries. If there is an overlap, the
user will experience a temporary negative velocity to push them back in bounds. Projectiles work when the shoot button is pressed, going in the direction the
user is facing at a set speed.
The distance between the enemy tanks and the user is calculated through Euclidian distance. If the enemy detects a boundary, it will temporarily be redirected in
an attempt to go around to reach the player. The enemies have a random chance to shoot a projectile if they are in direct view of the player without a boundary in between
the two. Each enemy tank has a health integer that is decremented whenever a projectile collision is made.
Lastly, the pause screen gives the player the ability to dynamically introduce obstacles, as seen below. When toggling the grid button, a generic default grid
is shown. Through clicking a cell, that section is mathemtically marked as a [1] within a 2D array full of [0]. When changing the size of the grid, the array is mathemtically
grown or shrunk depending on the direction. This array is also used with the collision function to prevent the player and enemy from going through.
This was where the bulk of the math came in, and one of my main tasks with the project. I needed to create a robust system that allows for dynamic
changing of size. Whenever the game was unpaused, the black obstacle boxes would remain and would be a part of the game environment. Going back to the grid menu and clicking them
again will allow the user for individual removal of cells.
This project aided in the opportunity for creating enemy ai within a runtime environment. These ai and the user will be faced with various points of collision.
It offered as a brilliant method to get hands on experience utilizing different algorithms learned in class. At the same time, the professor was extremely hands off,
leaving my team and I with only each other for help. This was a great way to brainstorm ideas and collaborate to create a runtime from something as simple as the python
Turtle graphics library.
The most worthwhile skill gained from this project was thinking outside the box to create various functions from scratch to develop gameplay. There is a lot of math involved
with games, and I learned the importance of movement, calculating boundaries, and path finding.
Skills Learned: