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.
Bookmarks