用户:
NanocDik查看:0 回复:0 评论:0 创建时间:2021-07-12T15:40:58
【作品展示】

【作品介绍】
【作品源代码】
'''
Running Competition
'''
import turtle as t
from random import randint as r
import time
def move():
t.penup()
t.goto(t.xcor(), t.ycor() - 50)
t.pendown()
def end():
t.title('Competition Ended')
t.bgcolor('lime')
t.color('gray')
t.hideturtle()
t.write("S", align='center', font=('arial', 30, 'normal'))
t.write("/", align='center', font=('arial', 30, 'bold'))
move()
t.write("Competition Ended", align='center', font=('arial', 30, 'normal'))
move()
t.write('The Winner is '+winner+'!', align='center',
font=('arial', 30, 'normal'))
t.done()
for i in range(1):
winner = 'None'
try:
t.speed(0)
t.title('Running Competition')
t.bgcolor('lime')
t.color("red")
t.fillcolor("yellow")
t.penup()
t.goto(200, 0)
t.left(90)
t.pendown()
t.forward(30)
t.begin_fill()
t.forward(40)
t.right(90)
t.forward(40)
t.right(135)
t.forward(40*pow(2, 0.5))
t.end_fill()
t.penup()
t.goto(0, 200)
t.hideturtle()
tc = t.Pen()
tc.color('red')
tc.shape('circle')
ts = t.Pen()
ts.color('blue')
ts.shape('square')
tt = t.Pen()
tt.color('purple')
tt.shape('triangle')
tc.penup()
tc.goto(-300, 100)
ts.penup()
ts.goto(-300, 0)
tt.penup()
tt.goto(-300, -100)
except:
end()
continue
try:
t.title('3')
time.sleep(1)
except:
end()
continue
try:
t.title('2')
time.sleep(1)
except:
end()
continue
try:
t.title('1')
time.sleep(1)
except:
end()
continue
t.title('GO!')
mktime = time.mktime(time.localtime())
while True:
try:
tc.forward(r(-5, 10))
tc.left(r(-2, 5))
ts.forward(r(-5, 4))
tt.forward(r(-5, 10))
tt.right(r(-2, 5))
if time.mktime(time.localtime()) - mktime >= 3:
t.title('Running Competition')
except:
break
if tc.xcor() >= 200:
winner = 'RedCircle'
break
elif ts.xcor() >= 200:
winner = 'BlueSquare'
break
elif tt.xcor() >= 200:
winner = 'PurpleTriangle'
break
end()
【提示】
部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:
https://python.codemao.cn