Recently, I’ve been working in a team for the AGBIC Jam hosted on itch.io and we’ve made steady progress but whenever I’m working on something in the long term, I always need small short term projects around me in order to take a breather from time to time on a bigger project. Being a staunch supporter of roguelike games, especially Nuclear Throne, I thought I’d make a quickie roguelike. Here’s how I did it in 48 hours:
As I always do before trying something knew, I did a fair amount of research into how to make roguelikes. Procedural generation can be a tricky thing and can be discouraging when you try out an idea in your head that just doesn’t work the way you thought. Although I have had other successful attempts at procedural generation. After extensively reading about different ways of making roguelikes, I settled on a method that was similarly used in Nuclear Throne: Drunkard Walk.
STEP 1: FLOORS & CRAWLERS
The first step is to spawn a crawler. Depending on the IDE/Programming language you use, this could be done in many ways. Since I was using GameMaker: Studio, all I had to do was create an object. This object originally faces in one direction and every cycle, the object would randomly change it’s direction by either turning 90 degrees to the right, 90 degrees to the left, a complete 180 turn or it could carry on in it’s path. Regardless, after every turn it would check whether there was a floor tile underneath it and if there wasn’t, it would create one before moving in it’s new direction. By tweaking the chance a crawler could turn in a particular direction yielded many different maps. For example, not allowing the crawler to turn backwards made the maps longer width wise and a lot more narrower.
STEP 2: CORRIDORS
In order to allow corridors in the game and different paths, a crawler had a slight percentage chance to spawn another. Although, the larger number of crawlers around, the more likely a crawler was likely to destroy itself. Nonetheless, once I tweaked around with the chances a crawler could spawn and the chance it could destroy itself (both relative to the number of crawlers already around). This allowed for a greater variation in the maps
STEP 3: PRODUCT PLACEMENT
Now in order to create content in the game, I had to allow the crawlers to generate chests and turrets. I did this with a few simple rules. If the crawler made a 180 degree turn, it had a 50% chance of generating a chest. Furthermore, if a crawler destroyed itself, it also had a 50% chance of generating a chest. Lastly, if a crawler spawned another crawler, there was a chance it would spawn a turret. At the end of the generation, the chests had a chance to destroy themselves if they were too close to the player (plus a random modifier). You can see this in action:
STEP 4: ENEMIES
I spawned the enemies in a simple matter, depending on a certain tile’s distance from the player (plus a random modifier) and the number of enemy objects in the game, a tile had a chance to spawn an enemy on top of itself. This barely needs anymore explanation.
For the AI, I used my previous Finite State Machine engine which worked like a charm once integrated
STEP 5: PLAY THE SHIT OUT OF THE GAME
Well this part isn’t that necessary but it’s easy to get distracted making a procedural generated map than actually working on the game. Don’t be down on yourself for that. Embrace it.
I did most of this in the first 24 hours while I tweaked it in the second while adding some better looking assets (and a modified sepia shader to make the game look more spaghetti western).
STEP 6: SHOW THE WORLD SCREENSHOTS
While I still consider this heavily under development, you can get what I’ve made so far here: Download Now
Your feedback would be much appreciated.