Friday, 14 July 2017

Remaking level generation

Since the map holds Tile objects it doesn't make a lot of sense to create objects for each map tile, but only those you can see. This idea led to another one when I was thinking level generation from a new perspective. In short you start from a level of null tiles and create open areas first (floors). Things like caves and passages between them, rivers and other natural areas. Walls don't exist yet, in fact they could be created after everything else is done, for rooms too. So the generation scheme would be two stages: first floors (and other tiles that are on floor level) and then walls/obstacles on top and around floors on empty areas. Also, I guess that way you could always make sure that everything is connected, other than areas you would later seal off with obstacles etc.

When digging to an empty area tiles would be generated around that place to avoid the player to reach null tiles. The only downside is that this will take some time... but I think it will be worth it and it's only a kind of minor shift in paradigm from carving stuff out from full rocky level to creating floor areas first on empty void and then building walls later in places they should go.

Sunday, 9 July 2017

Level class structure

After couple of days the final form of level class structure is ready. The difference to my initial plan is that there is one more class. They are:

Gen_Level: This is the base class which contains only the map for tiles and handling simple tasks such as low level get/put tiles.

Shape_Level: This class has routines to create different shapes of terrain tiles. Again, this class is kept very low level.

Object_Level: This is the new class that contains game objects and also room objects. The previous Object_Shed class was copy-pasted into this directly. It also was designed to relieve the amount of lines from that massive Level class that I had, but I realized it can be made a part of the class hierarchy.

Sequence_Level: The dungeon generation class with different parts activated depending on level theme.

Level: Gameplay part of the level structure which has routines that game objects use during the gameplay.

After this there are special themes derived from Level that override some creation procedures. This split seems to work quite nicely and it surely has made the management of code easier already. Level class still has quite few creation related routines which are moved either to Object or Sequence level. When this is ready I can continue working on creation routines of some level themes.