|
|
|
|
|
|
|
|
|
|
4 Way Map Movement (Moving through tunnels)
|
By: Kevin Picone Added: May 28th, 2011
|
Category: All,Maps,Collision
|
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.
Code built with PB1.64N beta 4 (may need changes for older versions)
|
|
|
Download:
Login to Download
|
|
Release Type:
The source code & tutorials found on this site are released as license ware for PlayBasic Users. No Person or Company may redistribute any file (tutorial / source code or media files) from this site, without explicit written permission.
|
|
|
|
|
|
|
|
|
|
|
|