An Island in the Clouds

Despite what the title of this post may suggest, I’m not going to be talking about some recent trip to Borneo or Papua New Guinea (although how cool would that be!) No, instead I’m talking about my continuing dalliance with the plasma fractal I mentioned in my last procedural content post.
While I used plasma fractals to create variations of the floor tiles in my procedural cave, there are many other applications for plasma fractals. One of the classic applications of plasma fractals is generating heightmaps. By imagining the value at each cell of a plasma fractal as the height of ground at that point, it’s relatively easy to visualize the mountainous terrain that can be generated with a plasma fractal. Traditionally, people use heightmaps values to perturb a 3D mesh grid to create 3D terrain. Since I already had the necessary pieces at my fingertips, I decided to see how my plasma fractals would look when rendered with 2D tiles. Continue reading

Virtual Spelunking: Procedural Textures (or How to Make a Dirty Floor)

One of the main advantages of procedural content is being able to generate a near-infinite number of variations on your content without having to waste valuable artist time. This is especially true when you want to make variants on what is generally “boring” background content, like rocks, trees, walls, and floor tiles. Instead of having an artist make 10 variations of rocks for your level, you can simple have them make one (or none!) and create 100 variations by applying perturbation functions to the content in code. Continue reading

Virtual Spelunking: Exits and Treasure

I’ve spent several posts detailing how to procedurally generate a cave for a player to explore. Now, it’s about time for me to fill that cave with things for the player to do. The most basic goal for any player dropped into the middle of a cave is to find a way out, so the first thing I’ll do is drop a starting point and an exit point into the cave. Just trying to escape a cave by itself is a little too sparse though, so I’ll also add treasure for the player to find and collect while they’re looking for the exit. Now, it’s starting to sound like a real game. Continue reading

Virtual Spelunking: Turning on the Lights

Continuing my adventure in interior decoration for imaginary places, it’s about time for me to start populating my procedural cave with objects. This time around, I’ll focus on adding light sources to my cave. There are two major reasons for this: 1) light sources, like torches, won’t have to be collidable so I can lay them out without worrying about breaking the navigability of my cave; 2) rendering the lights gives me an excuse play around with pixel shaders.

In order to lay out the lights, I need to come up with rules for their placement that will produce results that are neither too regular nor too random. Since I’m planning on eventually rendering the lights as wall-mounted torches, I need to make sure the lights are located on cave walls and not lying some place in the middle of the floor. I also need to make sure that the lights I place are on walls neighboring floor tiles, otherwise I might end up with lights buried inside large wall sections. Continue reading

Virtual Spelunking: Decorating the Floor

With the basic shape generated and tile rendering logic in place, my procedurally-generated cave is ready to be navigated. Unfortunately, it’s still a little bland since all the wall and floor tiles look the same. Worse still, this means that the player would likely have trouble distinguishing between different areas of the map. What we need is a little bit of visual variety to help give each area of the cave a unique visual signature.

To accomplish this, I decided to start by adding more visual detail to the floor. Of course, I could just randomly pepper the ground with detail tiles, but this would a) look random and b) do nothing to help the player distinguish different areas of the floor from each other. So, I needed a way to create distinct regions of like details on my map. I found a method to do this in a rather sentimentally-named cellular automaton called “Togetherness”.
Continue reading

Virtual Spelunking: Tiles and Shadows

Last week, I used a combination of algorithms to procedurally generate caves and render them on screen as arrays of ‘#’s and ‘.’s. While text-based rendering is great for debugging and Rogue-likes, sometimes you need something a little more graphical. Rendering the floor and wall spaces created by the random map generator as tile sprites should do just the trick.

For my cave tile rendering implementation, I decided to use some of the best, free graphic resources available on the web: Danc’s Miraculously Flexible Game Prototyping Tiles. In addition to being attractive, this tileset is also very easy to use because each tile is a self-contained piece. With the exception of shadows (which I will cover later), tiles don’t affect each other visually so you don’t need to change which tile you draw based on its neighbors. Because you can treat each tile as a self-contained piece it’s very easy to map a tile to the floor and wall spaces created by the procedural cave generator and end up with something like this:
Continue reading

Virtual Spelunking: Procedural Cave Generation

It’s easy to understand the lure of algorithmically generating game maps, especially for a programmer. A game using this technique can generate a near-infinite set of unique maps allowing it to be played over-and-over again. Generating random maps is the bread-and-butter of certain game genres, Rogue-likes for example, that thrive on such variety and replay.

There is a wealth of information on the subject of procedurally generated maps on the web. Particularly on sites devoted to the aforementioned Rogue-like genre of game. By using techniques documented on one such site and mixing in some well-known algorithms, I managed to implement a random cave generator that I think I’ll be able to use in a game or two in the future. Continue reading