View Single Post
  #2  
Old 04-30-2007, 10:46 PM
zokemon zokemon is offline
That one guy...
zokemon's Avatar
Join Date: Mar 2001
Location: Sonoma County, California
Posts: 2,925
zokemon is a jewel in the roughzokemon is a jewel in the rough
Send a message via ICQ to zokemon Send a message via AIM to zokemon Send a message via MSN to zokemon Send a message via Yahoo to zokemon
Quote:
Originally Posted by DustyPorViva View Post
Okay, say I have a number of directions, in this example, 16.
I have a set dir1, 6.
And I also have dir2, 1.

How would I get the 'distance', or in this case, the number of directions dir1 is from dir2?
I know in the example I posted with it, it's 2 directions away, but what would be the formula to do this? The problem arises since, like in the example, dir1 is 15, and dir2 is 1, so abs(dir2-dir1)=14.
If any of this makes sense, any advice?
I would suggest just doing something like:

dist = abs(dir2 - dir1);
if (dist > 8) dist = 16 - dist;
__________________
Do it with a DON!
Reply With Quote