pgzero icon indicating copy to clipboard operation
pgzero copied to clipboard

pgzero does not apply rotation to actor when image changed

Open JeremiahCheatham opened this issue 4 years ago • 1 comments

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 avatar Dec 09 '21 01:12 JeremiahCheatham

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.

JeremiahCheatham avatar Dec 10 '21 22:12 JeremiahCheatham