A closer look at the level generation in my "Diver vs. Mermaid" Unity project. The design, implementation details and explanations for level generation (including the cellular automata used) can be found in my GitHub repository:
https://github.com/pranigopu/diver-vs-mermaid
Check the following link for a brief gameplay showcase of the project:
https://www.youtube.com/watch?v=sJMKtEH5r3g
The level generator relies on random fill (based on preset proportions) to generate the initial grid (stage A), on which it them applies three cellular automata for a set number of iterations each (stage B). In these stages, the code works only with a 2D integer array (the grid variable in LevelGenerator.cs), altering the integers so as to represent the following tile types:
0 = Water
1 = Seaweed
2 = Yellow coral
3 = Red coral
Finally, we have post-processing (stage C) wherein we (1) place artefacts at random around the map (indicated in the grid by assigning the associated cell the integer value -1) and (2) generate the final level's tilemap. The tilemap implements the grid using tiles of the appropriate textures (they are auto-generated solid colour textures by default, but custom textures can also be applied). By default, the color-to-tile mapping is as follows:
Water = Blue
Seaweed = Green
Yellow coral = Yellow
Red coral = Red
Artefact = Black
In this video, I have focused on this project's cellular automata individually, seeing how each step adds to the previous one.
2 Comments