Here''s my idea...First once you have a path, divide it up into "checkpoints" and deal with each one separately. I''ll define a checkpoint as a point you can get to by going in a straight line without running into any obstructions. Next, determine at each tile, which direction (of the directions you have available) will lead you closest to your next checkpoint (i.e. project a ray in each direction from the current tile and see which one passes closest to the next checkpoint). You can do this all at once or reevaluate it each tile. I think that makes sense....hope it helps.
______________________________
And the Phoenix shall rise from the ashes...
--Thunder_Hawk -- ¦þ
______________________________
path finding question - refrasing
Does that make any sense? I only ask because it seems, to me, to be a perfectly viable solution to your problem.
actually, it does...
after i divde it to checkpoints (as you defined them) i have no problem choosing the direction image, i find the angle and divide it by 18 (i have 20 directions and 360/20=18) and the number i got is the index of the direction when 0 is facing right)
now what i am not sure is about how to devide to the checkpoints...
after i divde it to checkpoints (as you defined them) i have no problem choosing the direction image, i find the angle and divide it by 18 (i have 20 directions and 360/20=18) and the number i got is the index of the direction when 0 is facing right)
now what i am not sure is about how to devide to the checkpoints...
actually, it does...
after i divde it to checkpoints (as you defined them) i have no problem choosing the direction image, i find the angle and divide it by 18 (i have 20 directions and 360/20=18) and the number i got is the index of the direction when 0 is facing right)
now what i am not sure is about how to devide to the checkpoints...
after i divde it to checkpoints (as you defined them) i have no problem choosing the direction image, i find the angle and divide it by 18 (i have 20 directions and 360/20=18) and the number i got is the index of the direction when 0 is facing right)
now what i am not sure is about how to devide to the checkpoints...
If I''ve got your system right, it looks like the path you''ve determined only has right angle turns to go with your grid....
A quick (probably not the best) way to divide your path into checkpoints is to simply loop through using you current position and the next tile in line on your path and check if all tiles between them are ok to walk on. Pseudocode:
This isn''t the best because you obviously won''t walk on all of the tiles, just down the middle, but it really isn''t too bad to subdivide too much.
Hope that makes sense
______________________________
And the Phoenix shall rise from the ashes...
--Thunder_Hawk -- ¦þ
______________________________
A quick (probably not the best) way to divide your path into checkpoints is to simply loop through using you current position and the next tile in line on your path and check if all tiles between them are ok to walk on. Pseudocode:
TileCoords FindNextCheckpoint (TileCoords curPos, const TileCoords* path, int pathLength) { bool done = false; int index = 0; do { for (int i = curPos.y; i < path[index].y; i++) { for (int j = curPos.x; j < path[index].x; j++) { if (!IsTileWalkable(j, i)) done = true; } } index++; } while (!done && index < pathLength); return path[index - 1];}
This isn''t the best because you obviously won''t walk on all of the tiles, just down the middle, but it really isn''t too bad to subdivide too much.
Hope that makes sense
______________________________
And the Phoenix shall rise from the ashes...
--Thunder_Hawk -- ¦þ
______________________________
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement