键盘控制猫逃跑,需要配两个外部gif图片
QQ群交流936796850
import turtle
import time
import random
tom=turtle.Turtle()
def up():
tom.setheading(90)
tom.forward(20)
def down():
tom.setheading(270)
tom.forward(20)
def left():
tom.setheading(180)
tom.forward(20)
def right():
tom.setheading(0)
tom.forward(20)
playground=turtle.Screen()
playground.register_shape("tom.gif")
playground.register_shape("jerry.gif")
playground.listen()
playground.onkeypress(up,"Up")
playground.onkeypress(down,"Down")
playground.onkeypress(left,"Left")
playground.onkeypress(right,&