乌龟没有反应。 对于我正在开发的乒乓球游戏,即使正确给出了关键值,球拍也没有响应。
我尝试了 onkeypress 以及 stackoverflow 上某人的建议,但仍然不起作用。 我在传递我没有包含的函数时也检查了()。
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()
from turtle import Screen, Turtle
from paddle import Paddle
screen = Screen()
screen.setup(800, 600)
screen.bgcolor("black")
screen.title("My 🤪PONGIE😹")
screen.tracer(0)
r_paddle = Paddle()
r_paddle.goto(350, 0)
l_paddle = Paddle()
l_paddle.goto(-350, 0)
screen.listen()
screen.onkey(r_paddle.go_up, "Up")
screen.onkey(r_paddle.go_down, "Down")
screen.onkey(l_paddle.go_up, "w")
screen.onkey(l_paddle.go_down, "s")
game_is_on = True
while game_is_on:
screen.update()
screen.exitonclick()