I need to (re)add themes to the game. I used to have a “theme” concept, but it quickly turned into just “level definition”. The problem was that I was trying to customize too much, expecting to tweak everything, rather than separating only the data I actually tweak. In practice, I don’t have time nor inclination to do so. Most of my assets now seem to follow “good enough” mentality. Anyway, I need to restore theme concept so that I can have variation in the levels. I can’t currently swap the levels around because I have a fixed progression, so to speak.
Firstly, I’ll organize everything into folders:
I expect there to be multiple layouts and multiple themes and I already have multiple definitions.
Then on to my favourite part: creating more assets!
What I need specifically is a way to store and select themes, and so a theme selection asset would do:
I also need to define individual themes and whatever unique stuff they have, so an asset for that:
The way I currently see is that I need tiles and layout defined as part of a theme:
And now that I think about it, I can make my first level special layout logic by just part of a theme make specially for the first level:
Which also means I can simplify my layout definition assets and just have 2 for now:
Then add some logic to theme selections that selects themes based on the level, and randomly otherwise:
A look at my level definitions reveals that they are basically stuffed with redundant values (blue: same for all definition; red: not really needed; orange: theme stuff):
In fact, I don’t need separate level definitions as I can have a single one that gather all the common stuff:
Since I made all the selections, I can just look up stuff based on some property, like the current level number. This makes my whole list really clean:
So now I only have layouts and themes that are multiple assets, because they have truly unique values:
Of course, all of this was much messier than I documented. There’s a lot of wires running all through the code connecting it all. Thankfully, my architecture and dungeon generation are (I think) well-designed, and it took me hours instead of day to change.
Now, two things broke with this: level number and name. Fixing the number is easy — I just pass the current level/progression value to my level generator. I already have this value, because that’s how I record player’s progress. But I also broke the level name. I guess I really don’t have level “names” as such. But I can have a theme name, i.e. “Factory”:
And I can show the full level number + theme name in-game:
Now, there is an important gameplay consideration here. Themes should not be random — they are too big of a decision to be completely random. The player will notice if the same theme repeats or very different themes follow each other or variety is low or some such. I might go the route of pre-determined levels, but I don’t like this. I think the first level will always be a (variation of) starting/spawn area that fits the story. And then the levels become fairly random from there. The question is how I decide on this.
Firstly, I just want to generate a list of themes for the whole dungeon when I start the run (and be able to easily see/debug it):
I also need to save the list of these themes between executions, which means I need a unique ID for each theme:
Now I have to add a bunch of new placeholder themes. One really useful reusable debug check I have is to make sure I don’t accidentally link the same ID:
I have enough themes now and they are based on specific level ranges. I now need to “pad” my theme list nicely. However, before I select entries, I want to group them up so that my theme “padding” logic only processes specific ranges:
In this case, level 1 and 10 are always using only those compatible themes. But the 2-9 levels can use any of the themes that fit those levels. I also need to restrict the number of unique themes that can be encountered in the group:
Is this over-complicated? Yes. In the end, I get something like this:
First and last selections have no choice but to be the corresponding first/last themes. Now, I have 3 regular themes for levels 2-9 and 3 will get chosen. Then they get padded to be 2 of each to proportionally fill the group. And finally random ones get chosen to pad the remaining “slots”.
Good enough. I can always adjust depending on how much art I have and what sort of styling I am going for. I will probably have later levels have themes only seen in later levels, and same for earlier levels. That way, over time, the player associates certain themes with certain progression.
There are things I want to add to theming. Like certain props only spawning in certain themes (e.g. high-tech – blue batteries; maintenance – toxic battels, etc.). But I really need to hold off feature-creeping this. If I get art assets for this, I might consider things like these. For now, I still have a thousand things to fix and implement.