Last time the Dungeon was looking much better after being drawn on an HTML5 Canvas - there's even been a version created on DartLab! - (compiles Dart to JS in the browser so be patient!). This time we are going to take a step back to look at how the dungeon structure was made and then add a keyboard controlled hero.
There are many algorithms available for maze and dungeon generation - some very complex. The more advanced have steps to ensure there is a valid path from start to end. Our maze is based on a simple algorithm of defining a rectangular 'room' in a given space multiple times (restricted by our parameters for height and width). This is then carried out X number of times.
The list of rooms is then traversed and a corridor is constructed from room A to room B. Then B to C and so on. This means all rooms are in some way acessible. The overlaps of rooms and corridors create more interesting shapes. At this point we have only laid down floor tiles. A second scan of this map determines where walls and corner stones should be put.
The code has been tidied up and rearranged again - the Dart Editor makes this really easy to refactor and rename items. The new version can be found under the partthree folder.
Next time we will look at putting some items into the Dungeon, improving the generation and making more of a game display.