I am having some troubles getting my A* algorithm working correctly, or rather, implementing the path on my entities correctly.
I have successfully implemented this code into my game, it gets a path that avoids mountains and lakes.http://www.cokeandcode.com/main/tutorials/path-finding/
The problem starts when i want my entity to follow the path. My map is made out of 8x8 tiles, and the algorithm calculates the path according to the map array, which makes the path 512x512 pixels large, instead of 512x512 tiles large.
This creates a problem;
I am not able to create a path to anything outside a 512x512 pixel area on the map, since otherwise it would be out of bounds, i have tried to fix this problem, but dunno if its a correct way.
The unit does follow the path correctly, if i paint the path up, and then enlarge it over the map it is correct.
I have tried to fix the problem by making the algorithm to work with tiles by dividing the target x/y by 8, thus getting the position in tiles. Doing this f*cked it up though, so probably i have missed something somewhere. But my question is, is this the right way of doing it? The point is that i also want the units to walk pixel by pixel, but the a*star guides i have seen all goes by tiles, i dont think making a gigantihumongous array with every pixel on the map is a sane way of doing that.
The game i am trying to make is RTS, but the only tile based stuff on it is the map, think age of empires.