Skip to main content

Posts

Showing posts from October, 2019

Unity: procedure-generated levels

To begin with, let me give some explanation what was the original goal. As a weekend project I was writing a 2d game. And there was a need for a dungeon map: number of rooms somehow connected with roads. I think that it should be auto-generator, that will create various levels by input parameters (like number of rooms). At the very beginning I decided to divide the functionality into separate classes: one for generating level and another for rendering. Generator I have decided that generator has take maze X-length and  number of rooms to generate as input parameters. Additionally it has to try keep the Y-limit, but it is not so strictly as X-limit.  Well, generator will take these parameters in constructor: What about internals? I decided to use a container that can hold existing nodes and generate new one. I named it MapGrid. Inside it has a grid of nodes (List of List). First List - list of levels. It contains list of Nodes that have the same X-coordinate. On adding new N