Posted June 04, 2021 by 0xRobert
#Devlog #Game Design
Hello everyone!
Welcome to my VERY FIRST developer blog about my game: They Come At Night. This is a project I'm super excited about, and it's a weird enough blend of genres that I think others may be excited about it too.
Well.. it's a game about exploring, gathering resources, and building defensive towers to prepare against ever-increasing waves of enemies that come every night.
The game loops looks something like this:
I hope that sounds as interesting to you as it does to me.
Combining genres that aren't typically combined together creates some interesting design challenges. I started prototyping the idea a few months ago and things were going swimmingly until I hit a pretty big wall.
Note: I am not an expert! These are merely my opinions, and they are highly tailored to this specific game.
What do we think of when we think of Tower Defense pathfinding? Well, probably the most well known TD series is Bloons. In a game like this, the paths are created by the developer and all enemies will follow this path and head towards the exit. This is beneficial in many ways:
Okay, so what happens when we take the top-down TD formula and flip it on its side. Well, nothing changes really. The orientation has changed so maybe the art needs to be different, but we can generate a path in this orientation just as easily as in the top-down option.
This is what kicks off all of the design problems (for my game, anyway). When you add a player-controlled character that is subject to certain rules, all of the sudden anything that doesn't follow those same rules seems out of place. 2D platformers are all about jumping and falling. They are essentially Gravity: The Game.
If the player experiences gravity but the enemies float effortlessly through the air to get the exit, things look weird. Maybe you can design around it and make a compelling game, but wouldn't it be better if our enemies behaved in a way that fit the world a little better?
Okay, so let's create paths that look believable. The enemies won't float through the air and will appear as if they are jumping, falling, etc. We can have them path faster when they fall and slower when they jump. If it looks like they are subject to gravity just like the player, that's a huge win. This will actually work, and if your map is static, you can stop here! Congrats! (Well.. there are some other problems you have to overcome, but pathing is solved).
Okay.. but in my game the player can dig and manipulate the environment after every wave. This means we can't pre-generate a believable path for the map and must attempt to generate a new believable path every single wave! D: Furthermore, what if we want really big, fully destructible maps!? We have to generate a believable path for every single wave and we must do it efficiently!
There are lots and lots of resources on how to do pathing in games (though arguable less for 2D platformers) so I won't get into that. But I will tell you how I am approaching pathing in my game.
I'm using a very popular form of pathfinding called A-Star. I won't get into the details of how it works, but I will say that it is referred to as an "informed search algorithm". Basically, you give it a bit of extra information on what "may" be a good path to take, and it will often be able to find a good path more quickly than other pathfinding approaches.
In pathfinding you can define which paths are more expensive than others. For example, you can say "even though the valley on the other side of this mountain is technically closer, it's actually faster to just go around it". We can take advantage of this to simulate believable platformer pathing (keep in mind, this is specific to my game). In my game, I am severely punishing floating across open spaces. I tell my pathfinding algorithm that there is literally nothing more expensive than flying. I also tell my pathfinding algorithm that going down is basically free. By punishing flying and rewarding falling you coerce your algorithm into choosing to fall if possible.
Now, what if they need to go up? Well, in my game I am rewarding upward movement if (and only if) there is some ledge or wall to grab onto. This means the algorithm will choose to fall when possible, but climb walls when it needs to go up. This starts to look pretty good. Now instead of enemies just floating wherever they need to go, they start taking a believable path. They "jump" down ledges and "climb" up walls. Changing the speed they move when going down vs up adds A HUGE AMOUNT to making this look believable.
What if there is no wall for them to climb to reach the path? What if the player created a floating island?
Well, in that case they need to fly. ¯\_(ツ)_/¯ Even though we are severely punishing flying, enemies will still fly if they must.
This ended up being a lot longer than I originally anticipated so I'll stop here lol. I'll go over another topic in the future.
Thank you so much for reading and I hope you follow the project.
PEACE!