Im trying to make a function that takes an array of tiles, start tile and end tile, and returns an array of tiles from the start tile to the end tile.
basically:
i need to figure this out for a 2d topdown RPG-style game im working on. so far i managed to make it move from tileStart to tileEnd, but lets say there was a tile that blocked the path, it would just go right through it.Code:struct map { int x, y; bool bBlocked; }; struct tile { int x, y; }; tile *getTilePath(map *maptiles, tile tileStart, tile tileEnd) { //do something to figure out the shortest //distance between [tileStart] and [tileEnd] //in [maptiles] and return this path as an array }
an example of using the function would be, providing it a map of 3x3 tiles, with say the center tile blocked, it would look something like this:
00E
01C
SAB
1 means blocked. 0 is nonblocked.
If i wanted to find the way from S to E, it would return {A, B, C} etc..
could anyone post any links that might help or if possible a snippet that i might be able to use, im not sure where to start.
thanks in advance



LinkBack URL
About LinkBacks


