如何在Turtle中启用多个按键?

时间:2019-05-30 19:41:09

标签: python graphics

我正在尝试通过连续按下向上/向下或w / s键来控制两个板球的运动,从而确保我的Turtle pong游戏中的两个玩家能够同时移动两个板球。当前,两个玩家都必须连续按下按钮而不是按住它们-他们无法同时按下键和移动球拍。

wn.listen()
wn.onkeypress(paddle_a_up, "w")
wn.onkeypress(paddle_a_down, "s")
wn.onkeypress(paddle_b_up, "Up")
wn.onkeypress(paddle_b_down, "Down")
wn.onkeypress(pause_game_button, "p")

if (paddle_a_up, "w") ==1:
(paddle_a_down, "s") ==1:



wn.listen()
wn.onkeypress(paddle_a_up, "w")
wn.onkeypress(paddle_a_down, "s")
wn.onkeypress(paddle_b_up, "Up")
wn.onkeypress(paddle_b_down, "Down")
wn.onkeypress(pause_game_button, "p")

if (paddle_a_up, "w") ==1:
(paddle_a_down, "s") ==1:

0 个答案:

没有答案