python龟

from turtle import *
r=Turtle()
r.hideturtle()
r.shape('turtle')
r.up()
r.back(300)
r.left(50)
r.showturtle()
r.down()
def rmove():
    if usedtime<50:
        r.fordward(3)
    elif usedtime<550:
        r.setheading(0)
        r.forward(0.5)
    else:
        r.setheading(50)
        r.forward(4)
t=Turtle()
t.hideturtle()
t.shape('turtle')
t.color(0.3, 0.6, 0.4)
t.pensize(3)
t.up()
t.back(300)
t.left(30)
t.showturtle()
t.down()
def tmove():
    t.forward(1)
usedtime=0
def move():
    global usedtime
    rp=r.ycor()
    tp=t.ycor()
    if max(rp, tp)>300:
        w=Turtle()
        w.hideturtle()
        if rp>300:
            msg='r win!'
        else:
            msg='t win!'
        w.w(msg, align='center', font=('simfang', 30, 'blod'))
    else:
        rmove()
        tmove()
        ontimer(move, 100)
        usedtime=usedtime+1
ontimer(move, 100)
mainloop()
            

posted @ 2020-09-21 20:11  小松可可奈  阅读(147)  评论(0)    收藏  举报