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

[pygame] Make a sprite fall with realistic gravity?



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.