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

Re: [pygame] Make a sprite fall with realistic gravity?



On Mon, Nov 30, 2009 at 11:37 AM, Rob <robuck@xxxxxxxxx> 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.


cu,