Haunted Light – Generation Process

This week I’ve been mostly thinking and planning out how the level generation will work and I’ve also assisted our programmers in different parts of the game.

since I haven’t completed any new artifact in the game this week (except different resolution support…but it’s such a minor part and therefore I don’t’ count that) I’m going to talk about a feature of Haunted Light that’s a work in progress. The “(Re-)generating Levels”. I’ll explain what I mean by that.

Haunted Light is a game where you wake up on a basement-floor with only a single candle in front of you. As soon as you pick up the candle you notice that there’s a monstrosity following you and the goal is to survive by running away form that monster while avoiding critters and other horrors.

While you’re escaping you’ll notice that the rooms and corridors aren’t the same as when you previously were there. That’s because as soon as you move a large enough distance away from an area then it’ll change i.e. “re-generate“.

This is all done by the LevelSystem class which have access to the object-manager (which I covered in the previous post: ObjectManager) in order to create and destroy the walls in the generation-process.


A screencapture of the class; “LevelSystem” which this post will cover.

The way I accomplish this is by dividing the level into a grid and then divide each of those squares into a smaller grid. By doing so I have created a simple way of keeping track on each different area. Each slot in the larger grid is assigned a number through an int array which determines it’s status.

  • -1. Ignore
    This tile have already been generated.
  • 0 . Ignore
    The player is on this tile, don’t re-generate it.
  • 1 . Generate
    This tile have previously been visited by the player and need to re-generate.

Each time the Update() function in the LevelSystem class gets called from the GameState (I covered states last week: GameStates ) it resets the previous player position to visited status if the player have changed tile. Then it checks whether each tile have a value of “1” i.e “Generate”. And performs the Generate(X,Y) function.

The Generate() function then creates all the corridors and on-top of those, rooms where it’s needed. (This I’ll cover when I’ve written those parts of the system) The last thing that happens is that the value gets reset to “-1” and is therefore ignored until the player enters and leaves that particular tile again.

Now you know how I execute the update-loop of our LevelSystem class and if everything goes according to plan, then I’ll cover how the actual generation works next week!

~Lead Programmer, Per “Gimmic” Johansson

One thought on “Haunted Light – Generation Process

  1. It’s very clear and good read on what you’ve done for the generation of levels where at a set distance the level gets re-generated to make the map ever changing which will in turn make the game a lot more interesting if you back track in the game to turn a corner you went past earlier and suddenly it’s not the same room as it was a minute ago.
    But I was wondering what the game play value in this feature is?
    Since I’m not sure what the goal in this game is wouldn’t the randomly generated parts be a problem if you’re trying to get from point A to point B or is the game just to get away a certain distance from the horrors?

    I love the idea of the feature thou that your previous visited locations have changed and isn’t how you remembered it from earlier and get lost in the ever changing world. While frustrated and awe struck by the interesting mechanic while turning around for the first time and running the other way.

    It’s a great post but I would like to know more about why this feature have been added, to know the why this feature is there and the how this feature is made.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s