Part of a Generated Maze |
Mazes are a very fundamental part of video games. Most maps that the player actually plays through, be it a building, forest or cave, is really just a maze in disguise.
Part of a Maze with Multiple Solutions |
The algorithm is simple: Start with a rectangle, divide the rectangle in half with a wall and leave a gap or doorway somewhere along that wall. Then take each of the half rectangles created by this division and recursively divide them. Continue until the rectangle is the desired size.
A Maze with Wider Doors and Walls |
The most important part for me was the ability to control the size of the hallways and rooms. To create rectangular rooms I set it so that it would stop dividing rooms when they were between a certain size. To create long hallways, I set the width of the walls to be greater than one.
This algorithm is just a proof of concept for the moment, but I hope one day to use it along with my map generator to generate levels for a game.
No comments:
Post a Comment