-1
我正在創建一個遊戲,用戶使用鍵盤移動龜以避免另一隻龜。這是我的代碼:使一個龜龜追逐另一隻海龜
import turtle
playGround = turtle.Screen()
playGround.screensize(500, 500)
playGround.title("Turtle Keys")
run = turtle.Turtle()
follow = turtle.Turtle()
run.shape("turtle")
follow.shape("turtle")
run.color("blue")
follow.color("red")
run.penup()
follow.penup()
run.st()
def k1():
run.forward(45)
def k2():
run.left(45)
def k3():
run.right(45)
def k4():
run.back(45)
def quitThis():
playGround.bye()
playGround.onkey(k1, "Up") # the up arrow key
playGround.onkey(k2, "Left") # the left arrow key
playGround.onkey(k3, "Right") # you get it!
playGround.onkey(k4, "Down")
playGround.onkey(quitThis,'q')
playGround.listen()
我想要做的紅龜追逐藍色的龜,但它無法正常工作。任何幫助將非常感激!
不能說出爲什麼downvote這個問題。 – Kevman
你有什麼嘗試?爲什麼它不起作用? – tburrows13