Tower Defense + Platformer + Fully Destructible World = ???


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.

First off: WTF is this game?

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:

Daytime

  • Explore. The entire map is procedurally generated and you can change it by digging.
  • Dig into the ground to gather resources,  change the map to affect the path the enemies will take, and discover new caves.
  • Buy/craft/upgrade towers and place them in the world.

Nightime 

  • Watch as your murder-machine destroys all enemies that head for your base (or cry, as you discover your strategy isn't as effective as you thought it would be ;))
  • Manage your towers (not sure exactly what this entails yet, but you will need to manage some aspect of your towers during nighttime)
  • Help out. You have a firearm you can use to shoot at the enemies. You are basically a moving tower :)
  • Caveat: you can't dig or manipulate the environment at night. Whatever paths you have dug will remain the same until morning. Dig carefully.


WHAT THIS GAME IS NOT:

  • Terraria. Yes, it is inspired by Terraria, but the focus is on the strategic tower defense gameplay.
  • A survival/crafting game. There will not be any hunger/thirst mechanics and there will not be a bajillion things to craft. There may be some aspect of crafting, but that won't be the focus.
  • Finished. There is still a lot of work to be done and systems to be fleshed out. (However, the scope is very manageable,  I'm positive I can deliver a tower defense + platformer game given the current state of the project)


I hope that sounds as interesting to you as it does to me.


The First Design Challenge

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.

Pathfinding / Enemy AI

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:

  1. It's easy to program. There is only ever one path and you don't need to waste any time computing that path at runtime.
  2. It's understandable to the player. The player knows what path the enemies are going to take and can strategize accordingly.
  3. The movement make sense. This is probably confusing right now, but we'll get to more on this in a second.

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.

Adding the character

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).

Dynamic map

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!

A little bit o' pathing

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. 

Punishing bad behavior

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!

Leave a comment

Log in with itch.io to leave a comment.