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

Re: [pygame] time depending animation code



On Sun, 2006-05-28 at 17:24 +0200, DR0ID wrote:
> I'm trying to make a time dependent animation, but I'm not sure if I'm 
> doint this right. Please take a look:

This looks pretty close. The code you have for managing the looping
seems complex. It also looks like it won't be correct if multiple frames
have passed when it loops around.

def _update(self, dt, *args):
    """update frame on time difference, dt"""
    self._delay += dt
    numFrames = self._endFrame - self._startFrame
    dframes = int(self._delay / self._interval)
    self._idx = (dframes % numFrames) + self._startFrame
    # self.image = MyClass.images[self._idx]