The Drunkard's Walk
A downloadable template
A simple algorithm for procedural level generation in Construct 3. Whether you are about to start making your Rogue-like and cannot be bothered to write the level generation code yourself or would like to see how one works in action I got your back!
In brief, the code (and the algorithm) works like this:
- Initialize an empty array. In our case, 0 means there are not rooms in that cell, 1 - there is a room.
- Choose a starting position. By default it always chooses the middle of the array. You can also choose it to be random (see in code).
- Choose a random direction (up, down, left, right). See if that direction is within the array grid, if so mark that cell with a 1. Do this a "walk_length" of times.
- Repeat 2-3 "number_of_walks" times.
- Once done, loop through the array and create a room at a position where 1 is present.
The code is briefly commented out and includes some tips to how you can adjust the level generation to fit it in your game.
Distribution license:
All materials here are free to use for both personal and commersial projects. Selling it (adjusted or not) is not permitted.
PS
If you need help with the code, have found a bug, have some ideas on how to make it better please reach out to me on twitter @AtwoodPer
Tagging me on Twitter or just linking to this itch.io page would be very nice, but not mandatory. Consider donating if this helped you out and you would want me to make more of similar things.
Status | Released |
Category | Assets |
Rating | Rated 5.0 out of 5 stars (1 total ratings) |
Author | poppants |
Tags | 2D, assets, Dungeon Crawler, Open Source, Roguelike, sourcecode |
Download
Click download now to get access to the following files:
Leave a comment
Log in with itch.io to leave a comment.