Hey everyone.
So, it turns out that when you jump... you change directions. It's ok if people see you jump... but for people just walking into the screen, all they see is your old, predefined direction from before the jump. Firstly, here's a direction diagram:
[Only registered and activated users can see links. Click Here To Register...]
Based on that, you can probably imagine that when you jump, you face in the direction of whichever arrowhead you're closest to. Here's the formula I developed that can be used to find that direction:
EDIT: Updated formula: [Only registered and activated users can see links. Click Here To Register...]
It's a minor detail, but you know - I'm into those minor details.
Sincerely,
Spirited Fang
So, it turns out that when you jump... you change directions. It's ok if people see you jump... but for people just walking into the screen, all they see is your old, predefined direction from before the jump. Firstly, here's a direction diagram:
[Only registered and activated users can see links. Click Here To Register...]
Based on that, you can probably imagine that when you jump, you face in the direction of whichever arrowhead you're closest to. Here's the formula I developed that can be used to find that direction:
Code:
public const double RADIAN_TO_DEGREE = 57.295779513082323;
/// <summary>Find the direction of a character based on two points.</summary>
/// <param name="x1">The X Coordinate at Point 1.</param>
/// <param name="y1">The Y Coordinate at Point 1.</param>
/// <param name="x2">The X Coordinate at Point 2.</param>
/// <param name="y2">The Y Coordinate at Point 2.</param>
/// Developed by Spirited Fang - 2/18/2012
public static byte GetDirectionSector(ushort x1, ushort y1, ushort x2, ushort y2)
{
double angle = (Math.Atan2(y1 - y2, x1 - x2) * RADIAN_TO_DEGREE) - 67.5;
if (angle < 0)
angle += 360;
return (byte)(angle / 45);
}
It's a minor detail, but you know - I'm into those minor details.
Sincerely,
Spirited Fang