Tank Game
by Arnav Murulidhar
Description
James Bond has just escaped the clutches of the Russians! He has stolen one of their tanks and is desperately trying to reach the safe zone at the end of the map. His fate rests in your hands as you dodge bullets
fired from the enemy tanks that are in hot pursuit. Written in C++/openGL, the game has a pitch and yaw camera that follows the user, computer tanks that actively pursue the user, hierarchical models,
phong shading, collision detection, explosion visuals, and background music plus game sounds.
Features
- Pitch & yaw camera that follows the user's tank and points in the direction of the turret
- Hierarchically built tank comprised of a body, an upper portion and a turret. This allows the user to drive forwards while still having the turret point in another direction
- Projectile motion of bullets for user's and computer's tanks that travel in the direction of the turret
- Key based actions allowing the user to steer, move forwards and backwards, rotate the turret and fire
- Collision detection for all bullets hitting any tanks (meaning the computer can shoot itself), collision detection between tanks, and between tanks and the map boundaries
- Explosion visuals for when bullets hit tanks
- Ability to reset if user's tank gets hit or if the user wins the game
- Music using an external library (irrKlang) that allows for background music plus simultaneously played game sounds (bullet firing and explosions)
Model Controls:
- 'UP' : Move user's tank forward.
- 'DOWN' : Move user's tank backward.
- 'LEFT' : Rotates user's tank to the left
- 'RIGHT' : Rotates user's tank to the right
- 'A : Rotates user's turret to the left
- 'D' : Rotates user's turret to the right
- 'SPACE' : Fire's a bullet from user's tank if it has been more than 1.5 seconds since previous firing
Notes on Tank Movement:
- Tank moves in the direction of the body, not the turret, meaning the tank can move forwards while the turret is pointing in another direction
- User can simultaneously rotate the tank while rotating the turret and firing
- Tank can rotate on the spot
- There is collision detection between tanks, so computer can not continue to drive into user
- The camera view is based on the angle of the turret, so the user will always be seeing straight with the turret
Notes on Artificial Intelligence:
- Computer tanks constantly update their angle as to always be driving towards the user
- Computer tanks always move towards the user unless they have reached the collision threshold
- The computer fires a bullet every 3 seconds towards the user
- There is a random aspect, shifting the tank firing angle by 20 degrees in either direction of the user, allowing the user better chances of survival
Notes on Bullets:
- Each tank can have 100 active bullets at once, bullets become inactive once leaving the map or hitting another tank
- Each tank has a timer to regulate firing frequency, the user allowed 1.5 seconds whereas the computer must wait 3 seconds
- Bullets travel faster than tanks, so tanks cannot outrun bullets
Pictures
Initial view at the start of the game
User navigating map, dodging bullets
Explosion following collision of user's tank with a bullet. In the distance is another, older explosion of a computer tank
User reaches the goal!
Sources
- irrKlang external library for audio