On Mon, Nov 30, 2009 at 3:20 AM, René Dudfield <[email protected]> wrote:
> On Mon, Nov 30, 2009 at 11:37 AM, Rob <[email protected]> wrote: > > I've been trying to get a sprite (the ball) to fall from the top of > > the screen with realistic gravity. I did attempt it, however it's not > > so great so I won't post it here. > > > > I wasn't quite sure how to do it, I had it dropping per frame instead > > of per second, which meant it went about 60x too fast. I thought about > > dividing by 60, but then I figured the frame rate wouldn't be the same > > all the time. Also, the math seemed weird, because it would travel > > horizontally for a while before dropping (until deltay >= 1). I tried > > using math.ceil() but that made it unrealistically jerky instead of > > smooth falling. > > > > Can anyone give me a little example of a sprite class that falls with > > the effects of gravity? > > > > Thanks. > > > > > hi, > > have you looked at some of: > http://www.pygame.org/tags/physics > > There's a bunch of gravity using things there. > Agreed. I'd recommend looking at either pymunk or pybox2d for 2d stuff: http://code.google.com/p/pymunk/ http://code.google.com/p/pybox2d/ I've used pymunk quite a bit in my pygame stuff, it's pretty approachable. And PyODE has bindings to the Open Dynamics Engine for doing 3d, although I haven't messed with it at all: http://pyode.sourceforge.net/
