Technical features of the current demo of a tower defense game made using MonoGame and ECS architecture

Source code

Tiny War using ECS architecture

Overview

A 2D project in Computer Games Architecture - a module at City University of London. I used MonoGame framework and its ECS library to build the game and the related systems

Gameplay: Place either resource tower for money or war unit to defend against the upcoming wave of enemies

I. Technical features

1. ECS architecture

- The game is implemented around ECS architecture, using the ECS library from MonoGames.Extended.

- Some components include: BoxCollider2D, Bullet, EnemyComponent, UnitComponent, etc.

- Entities are ids and are created through the EntityFactory class by adding all the relevant components.

- Each system is responsible for a certain task (i.e: checking collision, rendering game objects, spawning enemies, etc.). The system is added at the beginning of the game when World is created. This is a part of the ECS library so that all systems are Updated/Rendered automatically after being added.

2. Input Binding & Collision System

- Dynamic key input binding using Command Pattern

- Collision is checked with distance check through collision system which fires 3 different types of event: OnCollisionEnter, OnCollisionStay, and OnCollisionExit

3. Data-driven design

- Each level is a text file indicating when and where to spawn the enemy. The LevelManager reads the text file and parses the information into a list of LevelInfo