sairate c5265add08 feat(第7讲 字母卡牌): 实现记忆游戏并添加开始界面
- 新增 jiyi.py 文件,实现字母翻牌记忆游戏功能
- 添加 youxijiemian.py 文件,创建游戏开始界面
- 使用 turtle 和 tkinter 模块分别实现游戏和界面
- 支持选择不同难度的游戏模式
2025-07-04 15:36:24 +08:00

28 lines
542 B
Python

from turtle import *
import random
tracer(False)#跳过绘画过程
bgpic("dot.png")
setup(1200,800)
t=Pen()
t.ht()#隐藏画笔
t.penup()
nei=0
total=0
t2=Pen()
t2.ht()
t2.penup()
t2.goto(380,-50)
while True:
x=random.randint(-200,200)
y=random.randint(-200,200)
t.goto(x,y)
if t.distance(0,0)<200:
t.dot(5,'yellow')
nei+=1
else:
t.dot(5,'magenta')
total+=1
pai=4*nei/total
t2.clear()
t2.write("{}\n\n{}\n\n{}".format(nei,total,round(pai,4)),font=("宋体",25,'bold'))
update()