News:

Function Finder  Find all the functions within source code files

Main Menu

4 Way Map Movement (Moving through tunnels)

Started by kevin, May 28, 2011, 11:42:13 AM

Previous topic - Next topic

kevin

   4 Way Map Movement (Moving through tunnels)

    This example lets the user navigate an object through a map. The  object is only allowed to move in 4 directions and the object is assumed to be the same size as a map tile.

    The path ways through the map must also be a single block in size,  so the object fits tightly. Normally this would mean moving through  the tunnel would require pixel perfect navigation.      To counter this, the movement code takes two approaches.  Firstly, there's check to see if the object is able to move in the requested direction.  So when the player presses up, we check the tile above, if that's empty they're allowed to move up.  If that fails.   We fall into a second phase, where we look at the tiles above and the left/right of our current position.    If one of those is empty, then we then translate the user up request, into either a left or right movement.  Which will slide them into position.  

    Video:

   




    Topics:

        - SpriteCollision - Sprite Collision - Maps - Sliding Collision    


    Related Links:

        - house hunter - Treasure Trove (wip)


    Download:

            Attached  Source Code built with PB1.64N beta 4 (may need changes for older versions)