I've taken a little time today to work on dungeons some more. Caves are good, but not quite what I am trying to achieve. I may refactor the caves some to be a mixture of natural caves and also carved out rooms. For the moment though I want more "man-made" types of dungeons. So I've started looking at maze generation and how that would work. I'll then move on to rooms and connecting them hopefully with the maze generation code.
I've been looking around and there are some very good and well documented ways of making mazes. Check out
this link from wikipedia and also
this one that is more comprehensive, though a bit heavier read. I've also been referring some to drow's
great resource here, though not using the source, just the brief description.
Here is my first phase of maze generation, using the same atlas as I made for the cave generation.
|
127x127 generation |
It also works for much smaller mazes.
|
9x9 map |
The project does have it's warts though. maps greater than 127x127 don't seem to render properly (the data seems to be there, maybe a cocos2d bug?) and non-square maps don't get traversed correctly. But all in all a decent depth-first recursive prototype.
Per usual you can get the source
here.
No comments:
Post a Comment