How to make a 2D dungeon crawler in 3 days
Added 2018-02-08 13:56:44 +0000 UTC

Hi all!
Here’s a post-mortem for Lands of TSR Lore , my tiny dungeon crawler made from scratch!
This was my 10th Ludum Dare and I thought I’d treat myself.
Early on I realized I will have no fun if I follow the theme, my ideas weren’t exceptional. What I thought was a fun idea about growth was, in fact, just an idea about leveling up in an rpg. Nothing better was coming, and since my internet connection chose that time to abandon me for 6 hours (yes, thank you internet gods), I felt less and less inspired.
Instead of despairing and spoiling all the fun for myself, like I usually do, I decided I’d just make a tiny rpg thingy. An old-school 2D (2.5D?) dungeon crawler, like Eye of the Beholder, Lands of Lore, Wizardry, Etrian Odyssey, the sort of games that felt magical to me, because the potential was there for a 3D world made of carefully pixeled pixelart. The closest pixelart can get to being immersive, without actual 3D transformations like wolfenstein (which kind of spoils it for me).
So, what went well?
First of all, a TON of code. I spent a ton more time coding than any other LD. I also spent a ton more time coding than I did content creation, which is refreshing because I’m always self-conscious that my art is better than my code is. Here’s all my “event groups” (it’s how Construct 2 allows you to organize code).

Each of those groups contains 3-4 dozen events. And not just if/then statements and quick solutions, I had to think hard about the algorithm that renders this:
into *this*:
Here’s the code by the way:
After a lot of headscratching, trigonometry saved the day: I made code that can read a bunch of 2d tile positions in the 4 cardinal directions at once, instead of having to input each separately. This code reduction is important, because tiles, monsters and objects (and later on, decorations) are going to be using the same function. Making changes is certainly easier the less code I have.
The basic idea was: the sine and cosine of 0,90,180 and 270 degrees have this useful property of having values of -1,0,1. So why not incorporate the code for checking for North/South and East/West in the same line, but multiply each half with either sin() or cos(), half the line is multiplied by 0, and the other half remains.
The inventory: I started this on a whim near the end, so you could pick up those shields.
Naturally I fumbled with the visualization code for the inventory and didn’t want to waste more time on it. Therefore all the shields you pick up just crumble to dust. I’m sorry ^-^’ The crumbly ancient shield graphic is from Eye of the Beholder by the way, I thought it was funny, since it’s a 24 year old game. I certainly feel old for having played it when it came out 
I made a wall set by using a 1-point perspective set of lines, and decided I wanted some extra bits sticking out in corners, for the thing to look more 3-dimensional (ergo the pillars in the front row)

I also thought how cool it would be to have the dungeon sort of smoothly transition from one tile to another, like Land of Lore first did. I probably used the same trick as they did, I used r0j0hound’s html5 canvas plugin for Construct, which allows me to take a screenshot and then manipulate it (scale it up) over the course of 3 frames, while also repositioning it to keep the horizon line level. This, along with mirroring the floor and wall graphics with each step (still a little buggy) gives a very solid illusion of moving forward, comparable to even recent AAA titles (Etrian Odyssey).
The whole game window is 192×108 pixels, smaller than SNES resolution, the height is smaller than even gameboy resolution. It’s the only way to get away with pixelart that looks good and polished.


Tiny screen size means it’s not overkill to have 11 frames of attack animation. It’s basically a 50×50 sprite, quite reasonable for platformers and such, and absolutely screen-filling at this size 


I like the dungeon music I wrote, inspired by Wizardry and Westwood studios’ brilliant Adlib music, using a Yamaha chip emulator called JuceOPLVSTi
More things that went right:
- I enjoyed myself! I’m going through a very rough personal time, with more stress than I’ve ever had, and yet on Saturday morning I was singing MISTER I’LL MAKE A MAN OUT OF YOUUUUUU from Mulan at the top of my lungs with a smile on my face.
- I felt alternately worthless and god-like while coming up with solutions to math problems
- a lot of code (under the hood) makes this a lot more complex and a lot more expandable than it looks. For example weapon slots are properly coded and will be fully functional once I make a proper inventory. Weapons have d20 stats, chance to hit is calculated based on Armor Class, strength bonuses apply, etc. It’s all rather pleasing for my geeky side.
- editing levels is a dream come true for me! Make a top-down tile-based map, as big or complex as I like, and it instantly gets shown in 3D. Through a 3D engine that *I* made, and completely understand. That’s magic for a person like me who lacks a lot of math knowledge that makes 3D representation feasible.
- the fact that our tools have come so far from 1991, that a single person can in 3 days replicate technology that was state of the art in AAA games back then, makes me SO happy to be indie
- I had one person say they *love* the game. That’s all you can hope for, that’s all you need, one person.
What went wrong:
- I didn’t match any of the themes. I don’t mind, but people do
- no gameplay apart from killing a few slimes and getting to the exit.
I know people make genius experiences for LD that last hours or have that wow factor and innovation. I admire and respect them, and hope I’ll have that spark of creativity myself some day. Until then, I’m happy to just chip away at little problems, learning to think like a coder, making game spaces I can explore. Thanks for being here for the ride and reading about it.
I love LD!
Comments
That 3D system looks incredible, congrats!
SuperBiasedGary
2018-02-12 10:50:21 +0000 UTCWow! I envy you, I wish I was that good at programming O_O Kudos!
TeamTailnut
2018-02-09 18:26:40 +0000 UTCAwesome, and with construct2 :3
Gillenew
2018-02-09 12:19:06 +0000 UTCEPIC JOB.
Daniel Scofano
2018-02-08 15:43:23 +0000 UTC