[Python] Issue with the movement of paddles in pong game using python turtle

Discussão em 'Python' iniciado por Stack, Agosto 23, 2025.

  1. Stack

    Stack Membro Participativo

    Turtle onkey is not responding. For the pong game that i am working on the even though the onkey values are given correctly, the paddles are not responding.

    i tried onkeypress as well as suggested by someone on stackoverflow, still doesnt work. i also checked when passing the function i did not include().

    from turtle import Screen, Turtle
    from paddle import Paddle

    screen = Screen()
    screen.setup(800, 600)
    screen.bgcolor("black")
    screen.title("My PONG")
    screen.tracer(0)


    r_paddle = Paddle()
    r_paddle.goto(350, 0)
    l_paddle = Paddle()
    l_paddle.goto(-350, 0)

    game_is_on = True

    while game_is_on:
    screen.update()


    screen.listen()
    screen.onkeypress(r_paddle.go_up, "Up")
    screen.onkeypress(r_paddle.go_down, "Down")
    screen.onkeypress(l_paddle.go_up, "w")
    screen.onkeypress(l_paddle.go_down, "s")


    screen.exitonclick()

    Continue reading...

Compartilhe esta Página