lordmauve / wasabi2d

Cutting-edge 2D game framework for Python
https://wasabi2d.readthedocs.io/
GNU Lesser General Public License v3.0
154 stars 24 forks source link

Animation finishes faster than expected #61

Closed encukou closed 3 years ago

encukou commented 3 years ago

This demo should result in a smoothly moving circle:

from wasabi2d import animate, clock, Scene, run

scene = Scene()

circle = scene.layers[0].add_circle(
    radius=30,
    pos=(30, 300),
    color='red',
)

async def move():
    while True:
        current_x, current_y = circle.pos
        await animate(
            circle,
            tween='linear',
            pos=(current_x + 50, current_y),
        )

clock.coro.run(move())

run()

Instead, the movement is jerky. This is because the mutable NumPy array used in the primitive's pos is also used as the animation's initial value.

lordmauve commented 3 years ago

Oh, wow! That's the cause of #36!

Great spot!

lordmauve commented 3 years ago

(I strongly prefer non-mutable vector classes; our hunt for a fast and non-mutable vector class to use for Transformable.pos is #17)

lordmauve commented 3 years ago

I think just adding a tuple(initial) would be the most general fix, in any case.