Results 1 to 2 of 2

Thread: [RESOLVED] Picture Collision Detection with Key Movement...

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2013
    Posts
    127

    Resolved [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?

  2. #2
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    6,582

    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.

Tags for this Thread

Posting Permissions

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



Click Here to Expand Forum to Full Width