Spores of Malice
Spores of Malice was made using C++ in TGE, a DX11 graphics library provided to us by the school. It is a top-down shooter based on Enter the Gungeon.
During this project I contributed, among other things:
Grid for more performant collision calculations.
AStar pathfinding for enemies.
Dynamic camera based on the one in Tunic.
Shadow-mapped directional light.
Some of the things I brought with me from previous projects include:
Grid for efficient collision calculations
Partitioning the world into a grid allows us to drastically reduce the amount of collision calculations needed. Instead of all entities calculating collision with all the other entities, collisions are instead only calculated with entities that are in the same or an adjacent cell.
This drastically improves performance. Previously, if the player were to shoot a weapon in a level with 1000 enemies, we would have to perform 1000 collision checks for that single bullet, even if it’s far away from any enemies. With the grid, the worst-case scenario is reduced to a handful, depending on how close the enemies are standing.
Pathfinding through A-Star
Utilising the grid, enemies calculate a path towards the player. The A-star algorithm works by recursively calculating a score for every grid cell it passes through on the way to its goal. This score is based on how far away it is from the goal, how far away it is from the starting point, and can also include, for example, if the grid contains any difficult terrain that would make it harder to move through it.
Once the goal has been reached, it backtracks through the cells, always picking the one with the lowest score, and saves the path for the enemies. Although it’s not always guaranteed, most of the time this results in the shortest possible path from enemy to player.
Some gameplay showcasing the pathfinding. As the player enters the room they are behind cover. The enemies move towards them.
Dynamic Camera
Since our reference, Enter the Gungeon, is 2D and our game is 3D, we decided to change the camera perspective slightly and lowered it. This made it hard to see enemies behind cover, and made it unclear where exactly you were aiming. To remedy this, I implemented a dynamic camera inspired by Tunic. While outside of combat, it’s fairly low to better show off the 3D world. When in combat, however, the camera raises to give the player a better overview of the situation.
Using a look-at matrix, our camera directs itself towards our player with a given offset. When the player enters combat, this offset is simply changed to be slightly higher, and the camera lerps towards it. Our offset also changes slightly depending on where the player moves their mouse. If the mouse is in the top right corner, the camera follows the mouse to give the player a better view of where they are aiming.
An early prototype of the camera. When “combat mode” is enabled, the camera raises to give the player a better overview of the situation
The final product. When the player enters the room, the camera raises. When all the enemies are defeated it lowers itself again. Also note that the camera somewhat follows the mouse.