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

Popping from a group freezes scale and rotation #63

Closed encukou closed 3 years ago

encukou commented 3 years ago

After a Group.pop, assignments to the popped object's angle and scale don't have any effect.

This code should draw a big star that should rotate continuously, but instead draws a small static star:

from wasabi2d import Scene, run, animate, clock, Group

scene = Scene()

star = scene.layers[0].add_star(
    points=5,
    inner_radius=5,
    outer_radius=50,
    pos=(scene.width / 2, scene.height / 2),
    color='green',
)

async def rotate():
    while True:
        star.angle += 0.1
        await clock.coro.next_frame()

clock.coro.run(rotate())

group = Group([star])

# This stops the spinning:
group.pop(0)

# No effect:
star.scale = 4

run()

The group.pop calls Group._factorise, which overrides the star's _Transformable__xfmat, so the star's __build_mat no longer writes to the right matrix.