Codename: 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“. 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.
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 |
