The main problem is that you set an offset to the body, even when you
have changed the image to have its center in the middle. If you remove
the offset from the body you will get collisions when the circles
overlap. (You had collisions all the time, just that they didn't occur
where you would expect :)

Another problem is that as soon as the two circles collide they will
move in the "physics world" but you never update their pyglet
positions based on this fact. If you don't want them to move, you can
return false from the collision callback function (then pymunk wont
move the bodies to resolve the collision). Otherwise you have to
update the pyglet car sprite positions from the bodies.

I don't know if you have seen it but there is one very small pyglet
example included with pymunk (the src dist). However, I don't think it
will give you much help as it draws the screen directly from the
pymunk objects and doesnt use pyglet sprites at all.

note: With the newest release pymunk will automatically reorder the
vertices if they are in the wrong order (unless its told not to).
Another useful tip If you are uncertain about the polygon winding is
to use pymunk.util.is_clockwise(..) or even simpler, just reverse the
list and see if things improve :)

/vb

On Aug 8, 2:31 am, dorzey <[email protected]> wrote:
> I'm trying to create my first game and after some research it seems
> pymunk might be a nice way to add some physics to my top down racing
> game; or at least take care of collisions for me.
>
> However, my attempt (http://pastebin.com/m6d5a81c1) to use it has
> faltered.  Whilst the body, shape and sprite all seem to be having
> their position updated correctly my program fails to recognise, and
> then handle, the collision. What am I doing wrong?
>
> I'm probably missing something really obvious, but google and the
> pymunk api don't seem to hold the answer.
>
> I'd also be interested in links to any tutorials/examples on using
> pymunk with pyglet.
>
> Thanks,
>
> Dorzey
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to