Tuesday, July 6, 2021

Fading Light Devlog 2: Public Launch!

Hey there! It's been longer than intended since my last update, primarily because of non-dev related stuff.  I'm now fully vaccinated against Covid-19 and since in my neck of the woods the vaccination rate is quite high I've been meeting up with friends and going outside and things like that.  My development pace has thus been a bit more leisurely than usual (although I'm pleased to report I never had a zero day) and writing fell by the wayside. But I hope to be more frequent and regular from here on out.

Anyway! Onto the game. The newest build (#3) is publicly available on my itch.io page, totally free, so give it a try and let me know what you think!


Anatomy of a Map

I mentioned in my previous devlog that one of the main features I hope to add to Fading Light is a random map generator. This update does not include that feature but a massive amount of dev time went into laying the requisite groundwork, including multiple different maps. To support randomly generated maps, a map needs to be clearly defined. So here's my approach:


 This is the Unity Inspector view of a map, which I have defined as a Scriptable Object. Each map has this 7x7 grid which defines what terrain chunks go where. Blank spaces are left null and will become wasteland (empty) chunks. Each chunk is pre-defined and is basically summarized by its icon in this grid. A chunk looks very similar, like this:

 As you can see, a chunk is also a Scriptable Object composed of a 7x7 grid, this time of tiles. Each tile corresponds to a Rule Tile I've set up in Unity, so I don't need to manually select each sprite to make it look like the road twists and turns or like the rocks and lakes actually line up correctly. I just specify which tile type (road, grass, mountain, water) goes where and Unity picks the correct sprite for me. This was fairly tedious to set up but ended up being a very worthy investment of time: now, making maps and chunks is very easy and I can focus on what I want to make instead of spending all my time doing data entry.

You can see that a chunk also has a chunk type, which I manually specify. If a road terminates as a dead-end, Unity knows it's meant to be either a start node or an end node, and I tell Unity which one it is with the chunk type (since a start chunk and end chunk are sometimes constructed from identical arrangements of tiles, Unity can't figure it out by itself). Likewise, if a road sits at a corner or an intersection it knows to put a vertex node there, which are the glowy things you click on to draw the path in the game. There are invisible path nodes as well, used exclusively for internal game calculations, which go on each straight road tile. Chunk types also have a few other uses: the tower building AI massively prefers not to put pickups or towers on start or end chunks, for instance.

When you start a new game, the map handler looks at the selected map and draws each chunk one-by-one. If there's no chunk there, that space becomes wasteland. Drawing a chunk is very similar: it reads the chunk and draws each tile one-by-one. Once every chunk and tile is drawn, there's some busywork under the hood that makes sure all the nodes are assigned and categorized correctly.

To make sure this all worked correctly, I added a map selector to the main menu and handmade 9 more maps (for a total of 10). The selector shows a preview of the map, which it does by simply drawing each chunk sprite as it appears in the array, the exact same way it's displayed in the first image above. So really, the only thing left for me to do is to make an algorithm that programmatically creates a map by placing chunks semi-randomly until a valid map is created. This is easier said than done, but now that I've isolated that problem I can focus entirely on it when its time comes rather than building the underlying map foundation at the same time. This is a core tenet of being an effective programmer: any unsolvable problem becomes solvable when you divide it into small enough sub-problems. If you divide and conquer, your gigantic mountains of work become totally doable individual jobs.


Eco-Fantasy

Fading Light was always meant to have a story, but right from the beginning I knew it wasn't going to have dialogue with characters or a heavy plot. It would be possible to include, but A) that would be a lot of work and would quickly over-scope my project, and B) I don't think the strategy genre lends itself too well to that. You can do it, but the story doesn't really meld with the gameplay: you find yourself swapping between story and gameplay rather than engaging with them both simultaneously and having them each support the other. In no small part I think this is due to the fact that strategy games are so zoomed out and impersonal: zooming into a character portrait talking, by its very nature, dramatically changes the tone and scope of the narrative. Engaging with that story, in this game, wouldn't be congruent with what you spend the majority of gameplay doing: buying things, drawing paths, and casting spells. 

Therefore, I chose not to do that kind of story. Instead, I chose to tell Fading Light's story almost entirely through the environment, atmosphere, and mood. There's a short paragraph on the itch.io page that sets up the setting, but that's about it in terms of words. The rest is communicated with background details, music and sound effects, and the gameplay itself. I'm not done implementing this stuff yet, but I made huge strides with this update. Let me go over some of them in greater detail.

The main menu now has a background of a backlit forest scene to accompany the haunting music. This was directly inspired by this free asset I found on itch.io by user Aethrall. Originally, I was going to just use this asset directly, albeit with a simple recolor. But when I tried implementing it, I decided wanted parts of it (leaves, branches, vines) to sway in the wind, rather than entire layers just parallaxing back and forth. So I decided to draw my own from scratch, clearly inspired by this piece but with its own feel. I also wanted a big tree on the left to provide a dark background for the menu buttons. Once this was done, I added some animated leaves which fall between each layer, and some subtle smoke rising behind the furthest layer, each implemented with Unity's amazing particle system. 

You can see in game that the background doesn't move aside from the particles, and that's because after I spent a couple hours animating it I found that I actually preferred the look of it as a static stack of images, with only the particles moving. The tone and feel I was going for was that the scene was peaceful, but in a subtly disturbing way. The completely still forest emphasizes the falling leaves (unusual since the colors suggest spring or summer, not autumn) and the rising smoke. However, you deliberately can't make out the source of these things: you just know something is wrong, creating a sense of calm unease before the more action-oriented visuals of the actual game.

Likewise, the map descriptions tell you you'll be playing around huge forests and dense undergrowth, but when you load in... well...


There are no trees, only muddy grass with hewn stumps and fallen branches, surrounded on all sides by a gently smoking ashen wasteland. Even though the game space itself only shows things that have gameplay relevance, my vision was for the tileset itself to show what the "despoilers" have wrought with their actions. Even though the music is full of energy as befits an action scene, it is anything but hopeful or cheery. The track I chose for this (from the wonderful Ultimate Music Bundle on itch.io) was even titled "Burning Forest."

So even though there isn't a script, or any named characters or anything like that, I hope I can still communicate the type of story that is occurring in this world. You have to imagine the blow-by-blow story beats yourself, but it tries to get all the most important bits across to the player. In forthcoming updates I hope to reinforce and expand on this further.


That's all I've got to say about Build 3. Hopefully I've accomplished the things I described above: if not, feel free to let me know how I could improve! I'm learning so much and having so much fun making games that I hope I can continue doing this for a long, long time. See you guys next time!

No comments:

Post a Comment

Post-Mortem: Protect & Serve

 A couple weeks ago I participated in my first ever game jam! This is something I've wanted to do for over a year now, but in the beginn...