I just complete my first game with flash (and flash punk) and it went well, learnt a lot. But i have a question.
I’m going to make a tower defence game but I want to make it as optimal as possible, both for making the game faster and secondly learning more optimal solutions.
My problem is that lets say i have one tower, but 100 different enemies
A) i could do the easy way of searching all 100 enemies to find the nearest one. Which i have done in java before many times
or
B) using the tile map, when a enemy walks along a tile it is put in a array which is linked to that tile which then the tower will check the nearest tile’s until it reaches a tile with a enemy on it, if the tile array is bigger than 1 then you know there is more than one enemy on it then it would just check the array length rather than all 100 enemies.
Is that a good idea or is there a better way of doing it ?