用户:
黄泉GR查看:0 回复:0 评论:0 创建时间:2023-08-09T13:49:11
【作品展示】

【作品介绍】
开始时迅速点击海龟,每次都有时间限制,找出一个颜色不同的海龟
【作品源代码】
'''你能闯到第几层?'''
# 1.导入库
import turtle as t
import random
import time
# 2.基础设置
t.hideturtle()
p = t.Pen()
p.speed(0)
# 3.背景场景
t.addshape('bg.gif')
p.shape('bg.gif')
p.stamp()
# 4.画笔外观
p.shape('turtle')
p.right(0)
p.shapesize(2)
p.penup()
# 5.变量设置
level = 0
j = 0.1
lst = [
(-45, 85), (-5, 85), ( 35, 85), ( -5, 45),
(-85, 45), (-45, 45), ( 35, 45), ( -5, 115),
(-85, 15), (-45, 15), ( 35, 15), ( 85, 15),
(-85, -15), (-45, -15), ( 35, -15), ( 85, -15),
(85,45)]
# 6.进入下一层
def next_level(x, y):
'''进入下一层'''
global level, j, lst
red = random.randint(1, 8) / 10
green = random.randint(1, 8) / 10
blue = random.randint(1, 8) / 10
p.color(red, green, blue)
for x, y in lst:
p.goto(x, y)
p.stamp()
x, y = random.choice(lst)
p.goto(x, y)
p.color(red+j, green+j, blue+j)
level = level + 1
j = j - 0.008
# 7.开始游戏
start = time.time()
while time.time() - start <= 20:
p.onclick(next_level)
# 8.结果显示
p.ht()
p.goto(-200, -200)
p.color('blue')
p.write('Robin', font=('Freestyle Script', 50, 'normal'))
p.goto(0, 0)
p.color('yellow')
p.hideturtle()
p.goto(-125,-50)
p.write('你真厉害! 达到了第'+str(level)+'层',font=('黑体',17,'normal'))
t.done()
【提示】
部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:
https://python.codemao.cn