2022 | University | SFML | C++
A cellular automata based terrain generator with destructibility.
This is a system I wrote for my group project during my second year of university. From the beginning of the project our group knew we wanted to add procedural terrain generation, with the destructible terrain coming as a group decision to prevent the need to create fully solvable levels due to time constraints.
The entire project was written in SFML and C++, using an existing game framework given to us.
It was my goal to write the terrain generation itself and the destruction, and I tried to make the systems as usable as possible for the other members of the team. The system is split up into several components:
- A dedicated terrain generator class handles the generation of the actual terrain, and comes with all the usual cellular automata features.
- A map class handles rendering the map and the destructible terrain aspects, and comes with many abstracted features and a small API for querying the map, collisions and destroying sections of the map. The actual “data” array of tiles is separate from the visual array for simplicity. A bitmask is used to correctly render “wall” sprites when terrain is destroyed.
- A “game level state”, derived from the framework’s gamestate, is used and which comes automatically with a map and terrain generator class, and handles setting up, updating, and destroying the map.
- Specific functions for spawning objects in the world, and “carving” out space for them so they fit without clipping into the terrain.
This was my first real group project, and from the beginning I knew I wanted to create a system that was easily usable by the rest of the team. It helped to create the groundwork for my interest in backend systems and tools.