[RESOLVED] Picture Collision Detection with Key Movement...
Using the tried-and-true algorithm to obtain the left, right, top, and bottom of a picture that I'm able to move around the form via the asdw keys, I can detect collision. That is not the issue. When I move my character to the left and it comes in contact with an object, I can stop it. The problem comes when I want to move to in any of the other three directions that it gets stuck. I've tried the "If my character hits the edge of an object, stop and then move away a few pixels", but then it just looks like it's bouncing. Collision detection is easy. Moving the objects with the keys, detecting the collision, and then moving away from them; not so much. Any ideas?
Re: Picture Collision Detection with Key Movement...
Change the order of how you move.
Instead of
1. Move
2. Detect colision
3. Move back
Try
1. Compute new position
2. If new position is not a collision set object to new position, else set object to sit next to the collision point.
If you don't move to an invalid position, you won't see a bounce as you move it a second time to "undo" the collision.