Skip to content

A 2D laser tank shooting game built by using C, Unix, and Makefile on Ubuntu.

Notifications You must be signed in to change notification settings

zongqiooi/laser-tank

Repository files navigation

animated

Laser Tank

A 2D shooting game in C.

Introduction · Features · Tech Stack · Prerequisite · Setting Up Locally


Introduction

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.

Features

  1. Player
    • Movement: Move by using the WASD keys
    • Shooting: Shoot by using the F key
  2. Enemy
    • Shooting: Shoot by the enemy automatically when the player moves into the direction where the enemy is facing
  3. Laser
    • Color changing: Switch in RGB colour when the laser travels each step
  4. 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)
  5. 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
  6. Log file
    • Saving: Save the log of game history using the L key or automatically saved when a winning or losing condition happens
  7. 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
  8. 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

Tech Stack

  • C - programming language
  • Makefile - utility tool for automation

Prerequisite

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

Setting Up Locally

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

About

A 2D laser tank shooting game built by using C, Unix, and Makefile on Ubuntu.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published