Game Development Community

dev|Pro Game Development Curriculum

1000 Dungeons

by Eric Armstrong · 09/18/2013 (1:48 pm) · 14 comments

Introduction

This blog post is an introduction to the Torque 2D game I'm working on and a highlight of some of the custom features and functions I've built for the game so far.

About 1000 Dungeons

1000 Dungeons is a Rouge like game of exploration, battle, and crafting. The game features 1000 randomly generated dungeons spread out over 10 different randomly generated lands. The goal is to make it through as many of the dungeons as you can. If you die in dungeon 999, you have to start over from number 1. To help you on your journey, there will be weapons to upgrade, items to craft, and varied creatures to hunt and be hunted by.

Features


World Generation

The first element I tackled for the game was creation of the randomly generated worlds. The world generation uses an algorithm based on a seed and grow process. There are 5 basic land types:


  1. Grass
  2. Water
  3. Desert
  4. Mountain
  5. Forest

Each terrain type can have a frequency value set from script before world generation. This allows the game to then control the primary terrain type for each world that gets generated. Terrain types play an important role in the game, as certain monsters will only be in a dungeon that is on a specific terrain type. And since the monsters drop the resources you need to craft items and upgrade weapons, making sure you get all the different creature types is important to being able to make it through all of the dungeons.

Here is an example of what the world might look like after seeding:
www.bloodytongue.com/images/InitialSeed.png
The frequency values across all terrain types totals 100, which is the number of seed tiles that will be placed in the world. Once the seed tiles are placed, the code loops through the map and starts to grow the terrain type it encounters into any empty cells adjacent to the current cell.

Here is what the above image would look like after one growth round:
www.bloodytongue.com/images/Growth1.png
This basic growth routine continues until all of the tiles have been filled. We now have a world.

All of the above is handled by a custom C++ class written and integrated into the T2D engine.

Dungeon Generation

The dungeon generation is another custom C++ class added to the engine. Dungeon generation is room based. It always starts with a random sized room in the middle of the dungeon. Once that initial room is placed, a random location is picked until a we find the wall of an existing room that doesn't already have an opening on either side of our spot. The wall is removed from that location and left as either an empty space, or randomly chosen to be a door. If at any point we loop 10000 times without being able to create a room, then we call the dungeon done.

Example image of a generated dungeon:
www.bloodytongue.com/images/RandomDungeonGG.png

Rendering of Worlds and Dungeons

Example of part of a dungeon being rendered:
www.bloodytongue.com/images/DungeonRender.PNG
Example of part of a world being rendered:
www.bloodytongue.com/images/WorldRender.png
The rendering of the world and the dungeon are both handled with the excellent new CompositeSprite object. When a world is loaded or generated new, the game builds a composite sprite querying the C++ generation code for the tile type and setting the sprite to the correct image. This allows me to easily swap out new graphics for each tile type and only have to make script changes.

Dynamic LOS Shadows

A dungeon crawl wouldn't be a dungeon crawl if you could see everything in the dungeon. To fix that, I added another new class to the engine that builds dynamic shadows based on the players position.

Example:
www.bloodytongue.com/images/JustShadows.png
This was a fun class to write as unlike the dungeon and world generation stuff, this actually renders to the scene, and is a new child of SceneObject. The object takes a copy of the current dungeon map and a radius value and automatically calculates the shadows for the walls of the dungeon based on the position of the player.

This code was based on the resource found on the site for dynamic shadows in TGB. Converting the code from that resource took a bit of time, but in the end, I got it all worked out.

Light

In addition to the dynamic shadows above, light plays an important role in the game. Including the color of the light. Time for another custom scene object. This one renders a gradient circle from the player getting darker as it moves away. This can be dynamically updated with size and color based on what kind of light the player has equipped.

Here is an example with a base yellow torch:
www.bloodytongue.com/images/ShadowLight.png
The color matters, because for some creatures, the color of your torch can weaken or strengthen them. All things the player has to find out as they crawl through the many dungeons.

That covers the custom C++ side of the changes I've made so far for 1000 Dungeons. In the next update I'll go over some of the script side systems I've implemented, including the inventory system (complete with drag and drop), event call backs and all sorts of fun stuff.

If you want to read more about the development of 1000 Dungeons, be sure to follow our page on IndieDB.

If anyone has any specific questions on anything or is interested in more details on anything, just ask here in the comments and I'll give you all the information I can.

#1
09/18/2013 (3:10 pm)
That's really cool! I do love a good Roguelike. Those dynamic shadows look really impressive.
#2
09/18/2013 (4:18 pm)
Nice, kind of reminds me of Dragon Warrior and Rogue at the same time.
#3
09/18/2013 (5:20 pm)
Nice work!
#4
09/18/2013 (7:06 pm)
Very cool!
#5
09/18/2013 (9:44 pm)
Thanks all. I'm getting pretty excited with how the game is coming together. The MIT version of Torque 2D has been really awesome to work with so far and has really allowed me to take the game where I really wanted it to go. I originally started the development of the game in Java using Slick2D, but once the Torque went open source, I switched back over to it (I originally went with Slick2D and Java as I wanted the freedom to open up the source).

Other than some oddness with the C++ random number generation, the conversion has been quick, and Torque has given me a much more powerful base to build off of.

I should be doing some semi-regular updates here about progress on the game, and maybe some in depth forum posts going into specific code changes/implementations for some of the systems.

Again, thanks for the comments, and be sure to check us out on IndieDB too!

Eric
#6
09/19/2013 (10:45 am)
Thanks for sharing this. I enjoy reading about how others are using T2D and your game is a great example. Hope you find the time to share more on the lighting and shadow systems, love the look.
#7
09/19/2013 (7:33 pm)
Awesome to see some progress being made with our beloved engine! Congrats Eric!
#8
09/19/2013 (8:38 pm)
Thanks for the kind words. You can find an initial post I did about the shadow development on IndieDB here. It talks a little bit about converting my original TGB code over to the MIT version, and some of the issues I ran into. I'll work on getting the second part up where I get them working (along with the video so you can see them in action) soon, and post a more code in depth look here on GG.
#9
09/20/2013 (11:04 am)
I'm getting a lot of Ultima III: Exodus nostalgia looking at this - and that is an awesome thing!
#10
09/20/2013 (12:56 pm)
Looks like fun, I'm a big fan of anything procedural-ly generated!!
#11
09/22/2013 (2:01 am)
procedural = sweet
#12
09/22/2013 (12:23 pm)
Posted a link to your blog on the Google+ community page

Keep it up Eric! Your progress is inspiring your fellow Torquers!

plus.google.com/109269375877948937787/posts/bcRyuDoUQ96
#13
09/23/2013 (9:02 am)
Awesome Simon, thanks for the link on G+. If there is interest, I would be willing do do some posts going into the actual code implementation for some of this. What say you GG community? Up for some C++ talking?
#14
09/25/2013 (1:26 am)
Would be interested in reading about the code implementation for your custom systems, sure.