用户:
摩天伦晒太阳查看:1 回复:3 评论:1 创建时间:2023-07-23T18:13:50
【作品展示】

【作品介绍】
这是一款考验眼力的游戏,点击中间圆圈即可开始游戏,时间为20秒,20秒内,看谁点的不一样的圆多,可在评论区比赛
【作品源代码】
'''你能闯到第几层?'''
# 1.导入库
import turtle as t
import random
import time
# 2.基础设置
t.hideturtle()
p = t.Pen()
p.speed(0)
# 3.背景场景
t.addshape("背景13.gif")
p.shape("背景13.gif")
p.stamp()
# 4.画笔外观
p.shape("circle")
p.right(0)
p.shapesize(2)
p.penup()
# 5.变量设置
level = 0
j = 0.1
lst = [
(-90, 90), (-30, 90), (30, 90), (90, 90),
(-90, 30), (-30, 30), (30, 30), (90, 30),
(-90, -30), (-30, -30), (30, -30), (90, -30),
(-90, -90), (-30, -90), (30, -90), (90, -90),
]
# 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.005
# 7.开始游戏
start = time.time()
while time.time() - start <= 20:
p.onclick(next_level)
# 8.结果显示
p.goto(-200, -200)
p.hideturtle()
p.pencolor("blue")
p.write('你真菜! 才达到了第'+str(level)+'层(功夫熊出品)', font=("华文行楷", 20, "normal"))
t.done()
【提示】
部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:
https://python.codemao.cn