- CC22: commandblockguy: Tower Defense CE
- 31 Mar 2019 11:06:44 am
- Last edited by commandblockguy on 20 Apr 2019 03:57:31 pm; edited 1 time in total
This is my thread for CC22.
I toyed with the idea of rewriting my CC20 water entry, which was originally supposed to feature an editor for ships, but decided against it because it would be a lot of work and gameplay wouldn't be that interesting.
Instead, I think I will make a reverse tower defense game, where the towers are already placed and you draw the path that enemies will take. There will be no money system; instead, towers gain experience by killing enemies. You can pick an upgrade for a tower each time it levels up. The shorter your path is, the more experience towers get. You can change the path between every wave, but not during the wave. You can see how big each wave is before starting it.
This encourages the player to, on smaller waves, redirect the path to towers that need leveling up, but at the risk of letting enemies escape. On larger waves, players should make longer paths that pass by many towers so that enemies have no chance of escaping.
I'll add some technical notes about implementation, etc. in a few minutes; I typed this out on my phone for some reason.
EDIT: sorry for the delay, had to do some IRL stuff real quick.
Basically, the path will be made up of line segments (as opposed to points or curves). I will store the path as a array of structs containing the point coordinates and distance from the start. Enemies will only store their distance from the start, which will be incremented by a certain amount each physics cycle. To figure out where to render the enemies, it will do a binary search of the distances to find the previous and next points and their corresponding distances. From there, it's basic algebra to find where the point at that distance will be.
Instead of calculating whether each enemy is within range of a tower each time it needs to fire by comparing 2D distance, all towers will figure out which parts of the path they can reach. Then, during gameplay, the towers only have to do a series of 1D comparisons to see if a particular enemy is within range. The list of enemies will also always remain sorted due to the nature of the game, so it would be very quick to find the enemy within range that is closest to or farthest from the exit. I could also have it find the weakest or strongest enemy with a little more work.
EDIT: Made a GitHub. Not much in it right now. https://github.com/commandblockguy/reverse-tower-defense
I toyed with the idea of rewriting my CC20 water entry, which was originally supposed to feature an editor for ships, but decided against it because it would be a lot of work and gameplay wouldn't be that interesting.
Instead, I think I will make a reverse tower defense game, where the towers are already placed and you draw the path that enemies will take. There will be no money system; instead, towers gain experience by killing enemies. You can pick an upgrade for a tower each time it levels up. The shorter your path is, the more experience towers get. You can change the path between every wave, but not during the wave. You can see how big each wave is before starting it.
This encourages the player to, on smaller waves, redirect the path to towers that need leveling up, but at the risk of letting enemies escape. On larger waves, players should make longer paths that pass by many towers so that enemies have no chance of escaping.
EDIT: sorry for the delay, had to do some IRL stuff real quick.
Basically, the path will be made up of line segments (as opposed to points or curves). I will store the path as a array of structs containing the point coordinates and distance from the start. Enemies will only store their distance from the start, which will be incremented by a certain amount each physics cycle. To figure out where to render the enemies, it will do a binary search of the distances to find the previous and next points and their corresponding distances. From there, it's basic algebra to find where the point at that distance will be.
Instead of calculating whether each enemy is within range of a tower each time it needs to fire by comparing 2D distance, all towers will figure out which parts of the path they can reach. Then, during gameplay, the towers only have to do a series of 1D comparisons to see if a particular enemy is within range. The list of enemies will also always remain sorted due to the nature of the game, so it would be very quick to find the enemy within range that is closest to or farthest from the exit. I could also have it find the weakest or strongest enemy with a little more work.
EDIT: Made a GitHub. Not much in it right now. https://github.com/commandblockguy/reverse-tower-defense