[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[pygame] Fwded Post



here's a forwarded message from a un-subscribed address
(which surprisingly _isn't_ spam.) :] i see rob just subscribed,
but just pass this along anyways

-------- Original Message --------
First, I'll get the intro stuff outta the way.  Pete - great piece of
software!  I enjoy using it; thanks.  I've been lurking on the email list
for a while, and playing with pygame for a bit too.  I've recently been
motivated to post this question to the group however, because its something
I dont' understand.

I've got a playable part of a game written (a poor asteroids clone) and have
tried to implement framerate independent movement with my sprites by using
the FpsClock class in the pytimer module that's available in the PyGame
repository.

My sprites run beautifully smoothly at some frame rates, and not at all or
very jerky at others.

The FpsClock.get_frame_duration() method returns the time in seconds since
the last frame.  Internally, it uses pygame.get_ticks() to determine the
time for each frame.  Since pygame.get_ticks() returns milliseconds, the
most precision that the get_frame_duration() method can return is
thousandths of a second.

This means that 100 frames per second, the quickest a frame can take is
0.010 seconds.  Say I have a Sprite that travels 10 pixels/ second.  This
means at 100 FPS, it will travel 10 * .01 = .1 pixels /second.

I make a sprite travel by setting a new center for its rect member.  Pixels
are whole numbers only and a Rect object can't be in-between pixels (can
it?), so how can I move an object 1/10 pixel or less.

Is the solution to cap frame rates so that the movement of slow objects per
frame is big enough?

Also - do frame rate independent movement calculations only make adjustments
for a small variation in frame rate?  Like when temporarily slipping from 40
fps to 20?  Or is it meant to smooth movement at *any* frame rate?

At first, I thought the answer was the latter, and I thought that my game
would work the same at *any* frame rate and found that this was not true as
frame rates got high.

Sorry if this {doesn't make sense|is a stupid question|is obvious}, I've had
much coffee this afternoon.  :)

-- rob

____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org