Gameplay Programmer
Using the rather limited visual coding of Construct 3, I created a fully customizable wave manager and AI for the enemies.
The Wave Manager uses a 3-dimensional array stored in a JSON file to encode all information needed to create a wave (the position of each spawner, what to spawn and how much). This JSON is loaded from browser memory on launch and then read at the start of every wave to position everything and call the function that instantiates an enemy.
The Enemy AI uses the A* algorithm, where enemies move as self-avoiding groups. To achieve this, I needed to either:
- Recalculate the A* map every frame, which would kill performance.
- Overwrite the behavior, which would make enemies behave unpredictably.
So, clearly I needed a better solution. Ultimately, I landed on a mix of both:
- Every 0.5 sec we recalculate the map around the enemies far from view, and every frame we do it for the enemies close to the player. Since the player focuses on close enemies, we sacrifice a bit of performance to make them highly responsive.
- If an enemy overlaps another enemy, we overwrite the pathfinding with a biased random walk. While overlapping, the enemy does not recalculate the A* map to save on performance.