Results 1 to 10 of 31

Thread: Collission detection on level ( source Travels doc + some other examples)

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #5
    There are two ways to counter the-getting-stuck-in-the-wall problem.

    1) Move away from the wall when you're inside it. (the preferred method)
    For example, you're moving to the left at 3 pixel/cycle. You're going to hit the wall in 11px. Meaning you'll end up in the wall (and get stuck) in 4 cycles. At the fourth cycle your position is 1px inside the wall, so you correct that by setting the sprite position 2 pixels back.

    2) Change the testwall function to include the direction. Meaning when you go to the right you only test if the right side of your sprite is inside a wall. If you're going left, only test if you with with the left part. This way you can still move if one side of your sprite is inside a wall.
    Last edited by Traveler; 15-08-2011 at 10:08 PM.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •