lordmauve / pgzero

A zero-boilerplate games programming framework for Python 3, based on Pygame.
https://pygame-zero.readthedocs.io/
GNU Lesser General Public License v3.0
530 stars 190 forks source link

pgzero does not apply rotation to actor when image changed #266

Open JeremiahCheatham opened 2 years ago

JeremiahCheatham commented 2 years ago

When rotating an actor if the image is changed for that actor the new image does not use the rotaton. If the rotation is modified it will carry on from that new images rotation. However if the the actor angle is assigned directly back to itself after the image is change then it still works. So there is currently a work around.

this code will show the problem. When the image changes it will not be in the correct angle.

ship = Actor("ship1")

def on_key_down(key):
    if key == keys.RIGHT:
        ship.image("ship2")
    if key == keys.LEFT:
        ship.image("ship1")

def update():
    ship.angle -= 1

def draw():
    ship.draw()

This code has the work around that basically just sets the angle back to itself after the image is changed.

ship = Actor("ship1")

def on_key_down(key):
    if key == keys.RIGHT:
        ship.image("ship2")
        ship.angle = ship.angle
    if key == keys.LEFT:
        ship.image("ship1")
        ship.angle = ship.angle

def update():
    ship.angle -= 1

def draw():
    ship.draw()

This bug is not present in the current dev version of pgzero. However that version is completely broken and has not had any attention to those bugs.

JeremiahCheatham commented 2 years ago

The reason why the title stated that pgzero current what you call the dev branch as totally broken because this bug is only a problem in stable in current it's not a bug. However current is broken so you must revert back to stable and deal with the fact that this bug is still there. The title is relevant to the bug and also points to a possible solution. I wish no one would change the except the op.