Portfolio

illustrations illustrations illustrations illustrations illustrations illustrations illustrations

JS tank game 2017

Published on Jan 01, 2017 by debnera on games

JS tank game 2017

Two player JS tank game 2017

A 2d topdown tank game designed to be played with two players.

GitHub Repository Playable demo

Theme: Learn JavaScript
Project duration: ~1-2 weeks of coding
Team size: 1
My task: Everything (solo project)

Tank game

This is my second JavaScript project. I was tired of not being able to find a good 2d tank game that can be played locally by two players. All other games were either boring, or poorly implemented. For example, being unable to turn while being too close to a wall leads to a really frustrating gameplay.

Features:

  • Randomly spawning powerups: Machinegun, Heavy gun and speed boost

  • Tanks do not get stuck to the walls. They are pushed back by the physics engine, which makes turning really smooth and pleasing.

  • Made from scratch with raw JS and HTML5. No pre-made physics engines or graphics engines were used.

  • Uses SAT (Separating Axis Test or Hyperplane separation Theorem) to detect collisions between two convex objects.

  • Randomly generates a maze by using randomized Kruskal’s algorithm.

  • Mazes are scaled based on browser windows size. Viewing the game on a small window results in smaller (or non-rectangular) mazes.

Problems:

  • All the code is in one file. I didn’t figure out any good way for splitting the code in to multiple files.

  • Not all browsers have support (or had at the time of coding) for EcmaScript 6 import statement and minifying all files to one would require ‘compiling’ after each modification. This was fine, when the project was under 500 lines, but with the current 1000 lines it is quite hard to read.


Similar Stories