Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags
(1 edit)

OMG, procedural level creation working(or at least, 90% of it). It's still kind of rough now, but, hey, it works(tm). I taught about using BSP, but it was complex and I was too lazy to search for tutorials on how to implement it(or implement it myself). So, instead of that, I decided to develop my own solution to the problem, faster, better, and buggier(?). Ok, since I'm not using tiled anymore, I used some code I wrote some time ago to create a tile map from a matrix of integers. In the matrix(which should be a square matrix), each int represents one type of tile and the map is generated from it using the number to decide the texture and weather it's solid or not, and the column/row to decide the position. It's simple.

Now, I only have to create a matrix and feed it to the Map class. So, I create rectangles(in tile coordinates) to represent the rooms, I apply some limitations on the size and position beforehand. I take care none of these "rooms" are overlapping, and connect them together. To connect them, I check whether they're aligned on the Y or X axis. If so, I create a straight corridor from one to another. Right now, the algorithm does not support L shaped corridors, so if two rooms cannot be connected with a straight corridor, they're not connected at all. Once, the rooms are placed and connected(kind of), I just loop trough the matrix and place walls around each room/corridor. Then I feed the matrix to the map class, and voilà, a dungeon-ish map up and running.

It's not perfect, but I'm really exited about it, as it's the first time I make something like this. And, it will save me the work of creating each map individually, although, now the maps will look crappier(at least, until I polish the algorithm, if I ever get to do so). I'll upload screenshots later, technical problems :p.

Edit: Now, instead of straight corridors, they're always L shaped corridors. Sometimes they end up being straight corridors anyways, because of some crazy logic with loops(?). Quite happy with the results