For those who don’t know what “procedural” means, here’s a simple explanation: it’s a type of programming where every time the game starts, something is different. Think about a maze — each time you enter it, the path changes.
The good news is that I managed to implement this in Dopamine Rogue. The “Mind Maze” is always different: new monster placements, different items, new exits — like the “Happy Stage,” which represents the peak of dopamine — and even the city itself, where houses, buildings, and mission locations change places each run.
The Reason I Almost Gave Up
Now let’s talk technically.
At the beginning of development, I started with the Mind Maze. After creating the demons and the environment, I tried to build the system that would make the stage procedural.
And well… I just couldn’t make it work.
I looked at examples from other games to see if I could adapt something, but nothing really fit a 2D game the way I needed. I even tried using AI to give me some direction — just a hint, a starting point — but AI has its limits. Nothing it generated made practical sense for my case.
The core issue was simple: the code couldn’t understand that the player needed a clear path to move through the level. I was generating walls and items randomly, but there was never an actual open path. It was just chaos. No flow. No playability.
I spent an entire week stuck. Not building anything new — just repeating the same mistakes, trying again and again. Eventually, I stopped working on it for a few days.
I felt discouraged. I even considered quitting development altogether. This game is a dream I’ve always wanted to bring to life, and the thought of giving up so early was crushing. I started questioning myself — maybe I wasn’t capable of pulling this off.
The Breakthrough
A few days later, still feeling frustrated, I grabbed my bike and went for a ride in the park. My mind kept circling back to the same problem.
And then something clicked.
Instead of trying to generate an entire path dynamically through pure code, I decided to design multiple paths manually. I know — that sounds like it stops being procedural. But for a 2D game, it’s actually very efficient to define exact coordinates for where floors, walls, and items should be placed, while still ensuring there’s always a valid exit and a playable layout.
It’s still procedural — just in a smarter way.
I created many different pre-designed layouts, and the game selects one randomly each time. Completely randomly. It’s very rare for a player to see the exact same scenario twice — unless they replay the game and unlock all endings multiple times.
I also applied this system to the city. Buildings, houses, and mission locations are randomized each run. The interiors (except for Emma’s house) remain the same — only their positions in the city change.
The Hardest Code So Far
Ironically, this wasn’t the hardest code I’ve ever written — because at first, I couldn’t even get it started.
But there was another system that seemed to be progressing, yet constantly broke in unexpected ways. That one eventually became the hardest piece of code I’ve written so far: the NPC life system.
And I’ll talk about that in the next post.