Scrolling Game Development Kit Forum
SGDK Version 2 => Help, Errors, FAQ => Topic started by: durnurd on 2007-04-11, 12:09:20 PM
-
I'm attempting to write a function that returns a SpriteBase.Direction indicating what direction, if any, the sprite has just been stopped from going. For example, if they hit a wall, floor, or ceiling:
public int DirectionStop()
{
Debug.Assert(this.isActive, "Attempted to execute DirectionStop on an inactive sprite");
if (Blocked(Direction.Down) || IsRidingPlatform())
if (oldY < y && dy == 0)
return (int)Direction.Down;
if (Blocked(Direction.Up))
if (oldY > y && dy == 0)
return (int)Direction.Up;
if (Blocked(Direction.Left))
if (oldX > x && dx == 0)
return (int)Direction.Left;
if (Blocked(Direction.Right))
if (oldX < x && dx == 0)
return (int)Direction.Right;
return -1;
}
This works in most cases (not counting dx-y/LocalDX-Y problems w/ platforms right now) except when moving along slopes. It seems to consider whenever you're moving along a slope to be blocked. Any idea why? It's called after ReactToSolid and SnapToGround.
-
Maybe my definition of blocked was bad/unclear. I think I defined it as "do you hit anything solid going in that direction?"
-
Well, do you have any suggestions? I suppose I would have to write another function similar to blocked, but... thicker? I can't think of a better word.
-
Well, do you have any suggestions? I suppose I would have to write another function similar to blocked, but... thicker? I can't think of a better word.
how about complex?
-
How about "CanMove"? (And I should clarify the description of "blocked")