[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] PyODE

Greg Ewing wrote:
Kris Schnee wrote:
does anyone know how to feed collision information back to the program outside PyODE?

That's pretty much what I do, except that I don't bother wrapping the
objects; every time I add a geom, I assign it an "object" attribute
which points to the game object. What about it isn't working? The only
"gotcha" I've found for wrapping ODE/Pyrex objects is that you have to
overload __new__ as well as __init__.

It was something about an invalid keyword argument that wouldn't let me call __init__ for the ODE classes to wrap them in my own; couldn't pass it the information I needed. I ended up using this solution (thanks to both of you!):

In one of my WIPs I'm using just the collision detection
part of ODE to do something like this. I maintain a dict
that maps geom objects back to the game objects they
represent. Then I call the collide() method of my geom
space with a callback that does the appropriate thing...

I quickly got to the point of having some platforms, wraparound from the sides of the screen, and a, uh, "griffin," that moves with flapping flight and notices who's higher when it collides with an enemy. You can probably guess what I'm thinking.


It occurs to me that having NPCs able to sense their environment requires things that ODE doesn't seem to do, like asking "How far down is the nearest platform?" or "Is there a ladder next to the player when they push 'Up'?" or "Can I see an enemy?" I would have to maintain a second database of some sort to keep track of where everything is, and if I'm doing that, why am I using ODE? Before downloading the thing yesterday I was using a homebrew set of "physics" functions that let me run, jump on things, and handle gravity, so short of suddenly deciding I want pendulums ODE might not be too useful to me.