On Fri, Jun 12, 2009 at 6:22 AM, Niels Egberts <[email protected]>wrote: > > Im interested in the answer of this problem but what I would do is if > the player is moving left and up, and its upper-left corner hits > another object. I would check if I bounced into the object to the > left, or that i am more to the right. > > Another way of saying: > The points where 2 (1 standing still and 1 is moving left and up) > squares collide is an rectangle. If the rectangle is width>height then > It bounced onto the bottom. If the rengtangle is height>width it > bounced on the left. > > I think that should suffice :-)
If you have relatively low movement speeds, and stable framerates, this will work fine. If not, you may encounter cases where the player can teleport through bricks. Another way to handle this collision is through rewind - you record the original position of the sprite, move the sprite to the desired location, and then check for a collision. If there is a collision, move the sprite back towards the original position (in a loop, pixel-by-pixel) until no collision occurs. -- Tristam MacDonald http://swiftcoder.wordpress.com/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "pyglet-users" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/pyglet-users?hl=en -~----------~----~----~----~------~----~------~--~---
