[Python] Code in Python Brython with moving an image

Discussão em 'Python' iniciado por Stack, Fevereiro 9, 2025.

  1. Stack

    Stack Membro Participativo

    The pony image takes a box of the background from where it was originally placed with it whenever it uses the move_pony function. I want only the pony to move and not take any background with it. The oupt looks like this enter image description here I don't want the entire pony box to move but only the pony. How can I fix this?

    set_size(500,400)

    castle = Image("https://codehs.com/uploads/7870869b7f83173c85a485528fe3f558")
    castle.set_size(get_width(),get_height())
    castle.set_position(0,0)
    add(castle)

    pony = Image("https://codehs.com/uploads/531804f0be469050b7b3960871112b83")
    pony.set_size(100,100)
    pony.set_position(get_width()-150 ,275)
    add(pony)

    def move_pony(event):
    remove(pony)
    if event.key == "ArrowRight":
    pony.move(5, 0)
    if event.key == "ArrowLeft":
    pony.move(-5, 0)
    add(pony)

    add_key_down_handler(move_pony)`

    Continue reading...

Compartilhe esta Página