A 2D shooting game in C.
Introduction · Features · Tech Stack · Prerequisite · Setting Up Locally
LaserTank is a 2D game that allows the player to control the movement of the laser tank and shoot a laser. The laser will be reflected when it hits the mirrors. After the game ends, all the 2D maps game history stored in a linked list will be saved into a log text file.
- Player
- Movement: Move by using the WASD keys
- Shooting: Shoot by using the F key
- Enemy
- Shooting: Shoot by the enemy automatically when the player moves into the direction where the enemy is facing
- Laser
- Color changing: Switch in RGB colour when the laser travels each step
- Mirrors
- Laser reflection: Reflect and change the direction of the laser into 4 different directions depending on the incoming laser direction (North, East, South, West) and mirror-facing directions (/ or \ mirrors)
- Map
- Boundary: Restrict the player and laser to move beyond the boundary
- Map size: Configurable map size by changing the first line in the "map.txt" text file
- Log file
- Saving: Save the log of game history using the L key or automatically saved when a winning or losing condition happens
- Game conditions
- Winning: The enemy is hit by the laser shot by the player
- Losing: The player is hit by its own laser due to mirror reflection OR the player is hit by the enemy laser when it moves into the direction where the enemy is facing
- Zero memory leaks
- Zero memory leaks: Achieved zero memory leaks with malloc and free functions for the map created with dynamic array and the game log history stored with linked list
Ubuntu environment is required to run the project. The Ubuntu on WSL2 in Windows can be installed and run with VS code in the following link: https://ubuntu.com/tutorials/install-ubuntu-on-wsl2-on-windows-10
Make sure you have downloaded Ubuntu as mentioned in the pre-requisites section and changed the environment to Ubuntu in VS Code
To run the app locally, you can run the following commands:
git clone https://github.com/zongqiooi/laser-tank.git
cd laser-tank
code .
sudo apt install make
sudo apt install gcc
make
./laserTank map.txt log.txt