Hello. Coming to you guys for the first time with a problem that’s been bugging me for ages and I can’t find a solution to.
So, the problem is: you are making a tower defense game. Your creeps are stored in an array. Your towers can slow.
Now, you can make it so that the towers will just shoot the first creep in the array that is in range, but if say creep[1] gets slowed and creep[2] doesn’t, then creep[2] might be the one that would reach the goal first, and I want him shot first.
You could calculate the coordinate distance between the goal and the creep’s position, but if we have say an “S” shaped track, it might give wrong results, with the creeps in the middle left corner registering as closer then the ones in the middle right corner.
I tried avoiding an A* or recursive computation of the path to avoid slowdowns in case of too many creeps, and therefore the paths are internally just MovieClips that have a flag that can be “up”,“down”,“left” or “right”, so that when a creep is in it it knows where to go.
So the only solution I can come up with is to recursively compute “creep has to go UP, then from the new point LEFT, then from the new point LEFT again, so 3 tiles till it reaches the goal” or something like that. But that might cause some slowdown when you have too many towers and creeps.
So, how would you guys do it? Any tips and suggestions are appreciated.