Scrolling Game Development Kit Forum

SGDK Version 2 => Help, Errors, FAQ => Topic started by: durnurd on 2007-04-11, 12:09:20 PM

Title: Stopped in what direction
Post 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:

Code: [Select]
   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.
Title: Re: Stopped in what direction
Post by: bluemonkmn on 2007-04-11, 07:05:18 PM
Maybe my definition of blocked was bad/unclear.  I think I defined it as "do you hit anything solid going in that direction?"
Title: Re: Stopped in what direction
Post by: durnurd on 2007-04-11, 08:32:33 PM
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.
Title: Re: Stopped in what direction
Post by: Jam0864 on 2007-04-11, 09:41:11 PM
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?
Title: Re: Stopped in what direction
Post by: bluemonkmn on 2007-04-12, 05:57:35 AM
How about "CanMove"?  (And I should clarify the description of "blocked")