Building a Grid-based Dungeon Crawler

After reading CrookedB’s Wizardry 4 LP and playing Legend of Grimrock, I decided I wanted to fuck around with a simple first person dungeon crawler. I love the look of old crawlers in this genre: cobblestone, timber framed buildings, and fog renderers.

Lands of Lore

Started with Java as usual, and GDX because of the success I had migrating another project over from slick2d. GDX isn’t perfect but it’s incredibly powerful and easy to get off the ground.

Started off as most projects do, with some sanity tests for loading images and positioning. At this point I’m still using the built in GDX model builders.

First attempt.

Notice that the textures on some sides of the cubes aren’t rotated correctly. That would stick with me until I finally started understanding UV mapping, and manually assigning corner order for new meshes. For the time being, though, I just rotated every cube 90 degrees on the Z-axis and ignored it.

I grabbed some Minecraft textures, created a map of zeroes, ones and twos for different textures, and added colored fog, and directional light. Already it was looking pretty good. Didn’t learn anything special at this point, but it was good to play around.

Looking prettier: better textures, colored fog, and positioned light.

This is where I started learning about billboards: textures mapped to a simple plane that either always face the camera, or are always aligned with the camera’s normal. Or at least, I think that’s the distinction. The difference is clear (sprites here are from Dungeon Crawl: Stone Soup).

Comparing camera facing and camera aligned billboards.

On the left, the billboards are “turned” slightly to look at the player. On the right, the billboards all face the opposite of the camera’s normal. So there’s no distortion.

This was accomplished with GDX’s Decal class, but the class doesn’t have the same surface area as the rest of GDX’s 3D rendering pipeline, so I couldn’t give it awareness of the fog and lighting environment setup:

Standing out brightly.

Standing out pretty brightly, huh? This is where I had to start diving closer to OpenGL and understanding the state machine a little bit better. I ended up replacing the use of the Decal class with my own implantation, culled from sources online and experimentation. Getting the billboards to be rendered with the correct fog and lighting was the easier part. The more difficult part was making sure they were facing the correct direction. At many points during this I would end up with billboards that only were visible from one direction, or were flipped vertically when viewed from the opposite direction.

I created a tiny gradient of sky-like colors, and set a timer so that the environmental fog would select a color from the gradient to match the time of day. Simple effect but super cool:

Using fog coloring to simulate sky colors.

I’m not sure if I’m going to take this project further, but I’d like to someday.