kkroep / Surreal_Gravity

Game for Minor Software Ontwerpen en Toepassen
0 stars 0 forks source link

Enhanced and rewritten procedural generation #21

Closed StevenH2812 closed 9 years ago

StevenH2812 commented 9 years ago

So there were quite some bugs with the old procedural generation and it didn't work smoothly. I rewrote the procedural generation algorithm completely. I switched to grid based procedural generation instead of continuous based. The grid based algorithm is faster, because it uses a matrix first to create the level in this matrix, and has a separate function that actually draws the matrix into the scene with game objects. This is much faster than having to use colliders on the fly. It allows more control, because you can edit the matrix "manually" to draw objects in the scene that you always want there to be. Also the grid based will ensure that different "spawns" will merge together flawlessly and that there will be no multiple gameobjects on the same spot (which was a bug with the old algorithm). Also using the grid based algorithm it is much easier to prevent the algorithm from generating blocks outside of the defined dimensions of the level (this did happen with the old algorithm).

Furthermore the algorithm changed in the sense that it is no longer completely random. There can be a maximum of one direction of change from each block to the next. This will make sure that the structures don't change too greatly from block to block, such that you are able to walk through the level more smoothly. I added some booleans that allow the creation of solid walls, so that if we please we may close the level down so you can't fly out. I also added the option to scale the probability of a certain direction, which makes the algorithm more likely to move in a certain direction, so that you can create a flow in the level in a particular direction.

20141121_153509