lordmauve / wasabi2d

Cutting-edge 2D game framework for Python

Home Page:https://wasabi2d.readthedocs.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Animation finishes faster than expected

encukou opened this issue · comments

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.

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

Great spot!

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

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