# 曲速飞跃作
# 开始前请先设置小甲鱼!
from tkinter import *
import random
import easygui as g
# 加载tkinter模块,easygui模块和random。
fen = [] # 分数为0
food = [1, 1, 1] # 食物为3
lei = [1, 1] # 疲惫值是2
xing = [1]
money = [1, 1]
time = [1, 1, 1, 1, 1]
def sleep():
fen.append(1)
lei.remove(1)
time.remove(1)
time.remove(1)
var.set("困了困了,睡了。。。疲惫值为" + str(len(lei)) + ",现在分数为:" + str(len(fen)))
if len(lei) == 5:
g.msgbox("小甲鱼被累死了。。。")
with open('fen.txt', 'a+') as f:
f.write(str(len(fen)))
f.write('\r\n')
exit(0)
elif len(money) <= 1:
g.msgbox("小甲鱼被穷死了。。。")
with open('fen.txt', 'a+') as f:
f.write(str(len(fen)))
f.write('\r\n')
exit(0)
elif len(food) <= 1:
g.msgbox("小甲鱼被饿死了。。。")
with open('fen.txt', 'a+') as f:
f.write(str(len(fen)))
f.write('\r\n')
exit(0)
elif len(time) <= 1:
g.msgbox("小甲鱼被老死了。。。")
with open('fen.txt', 'a+') as f:
f.write(str(len(fen)))
f.write('\r\n')
exit(0)
def eat():
fen.append(1)
if len(food) >= 1:
food.remove(1)
else:
money.remove(1)
var.set("吃货的梦想就是天天吃(*^▽^*),食物有" + str(len(food)) + " 还有" + str(len(money)) + "元。现在分数为:" + str(len(fen)))
if len(lei) == 5:
g.msgbox("小甲鱼被累死了。。。")
with open('fen.txt', 'a+') as f:
f.write(str(len(fen)))
f.write('\r\n')
exit(0)
elif len(money) <= 1:
g.msgbox("小甲鱼被穷死了。。。")
with open('fen.txt', 'a+') as f:
f.write(str(len(fen)))
f.write('\r\n')
exit(0)
elif len(food) <= 1:
g.msgbox("小甲鱼被饿死了。。。")
with open('fen.txt', 'a+') as f:
f.write(str(len(fen)))
f.write('\r\n')
exit(0)
elif len(time) <= 1:
g.msgbox("小甲鱼被老死了。。。")
with open('fen.txt', 'a+') as f:
f.write(str(len(fen)))
f.write('\r\n')
exit(0)
def work():
fen.append(1)
lei.append(1)
food.remove(1)
l = random.randint(0, 2)
if l == 0:
var.set("走,搬砖去喽!哎呀,老板心情不好,才给0元。气死我啦!现在分数为:" + str(len(fen)))
elif l == 1:
money.append(1)
var.set("走,搬砖去喽!555,居然才给1元。真抠门!现在分数为:" + str(len(fen)) + " ,还有" + str(len(money)) + "元")
elif l == 2:
money.append(1)
money.append(1)
var.set("走,搬砖去喽!给了我2元?……还行。现在分数为:" + str(len(fen)) + " ,还有" + str(len(money)) + "元")
elif len(lei) == 5:
g.msgbox("小甲鱼被累死了。。。")
with open('fen.txt', 'a+') as f:
f.write(str(len(fen)))
f.write('\r\n')
exit(0)
elif len(money) <= 1:
g.msgbox("小甲鱼被穷死了。。。")
with open('fen.txt', 'a+') as f:
f.write(str(len(fen)))
f.write('\r\n')
exit(0)
elif len(food) <= 1:
g.msgbox("小甲鱼被饿死了。。。")
with open('fen.txt', 'a+') as f:
f.write(str(len(fen)))
f.write('\r\n')
exit(0)
elif len(time) <= 1:
g.msgbox("小甲鱼被老死了。。。")
with open('fen.txt', 'a+') as f:
f.write(str(len(fen)))
f.write('\r\n')
exit(0)
def study():
lei.append(1)
fen.append(1)
fen.append(1)
money.remove(1)
var.set("互谅的广大盆友们,大家好!我是小甲鱼。欢迎大家和我一起入门学习拍森……现在分数为:" + str(len(fen)) + " ,还有" + str(len(money)) + "元")
if len(lei) == 5:
g.msgbox("小甲鱼被累死了。。。")
with open('fen.txt', 'a+') as f:
f.write(str(len(fen)))
f.write('\r\n')
exit(0)
elif len(money) <= 1:
g.msgbox("小甲鱼被穷死了。。。")
with open('fen.txt', 'a+') as f:
f.write(str(len(fen)))
f.write('\r\n')
exit(0)
elif len(food) <= 1:
g.msgbox("小甲鱼被饿死了。。。")
with open('fen.txt', 'a+') as f:
f.write(str(len(fen)))
f.write('\r\n')
exit(0)
elif len(time) <= 1:
g.msgbox("小甲鱼被老死了。。。")
with open('fen.txt', 'a+') as f:
f.write(str(len(fen)))
f.write('\r\n')
exit(0)
def play():
xing.append(1)
var.set("好开森好开森!我居然是小甲鱼心里的蛔虫!不就是8这个数嘛,嘿嘿嘿……")
if len(lei) == 5:
g.msgbox("小甲鱼被累死了。。。")
with open('fen.txt', 'a+') as f:
f.write(str(len(fen)))
f.write('\r\n')
exit(0)
elif len(money) <= 1:
g.msgbox("小甲鱼被穷死了。。。")
with open('fen.txt', 'a+') as f:
f.write(str(len(fen)))
f.write('\r\n')
exit(0)
elif len(food) <= 1:
g.msgbox("小甲鱼被饿死了。。。")
with open('fen.txt', 'a+') as f:
f.write(str(len(fen)))
f.write('\r\n')
exit(0)
elif len(time) <= 1:
g.msgbox("小甲鱼被老死了。。。")
with open('fen.txt', 'a+') as f:
f.write(str(len(fen)))
f.write('\r\n')
exit(0)
while True: # 主循环
msg = "小甲鱼游戏1.0"
title = "little turtle"
choices = ["开始游戏", "游戏规则", "历史成绩", "设置小甲鱼", "退出"]
choices = g.choicebox(msg, title, choices)
if choices == "开始游戏":
root = Tk()
zhuye = Frame(root)
go = Frame(root)
var = StringVar()
var.set("我是小甲鱼!你要干嘛?现在我好饱,有3点食物,疲惫值为2,只有3块钱,能活5岁。。。现在分数为:0")
textLabel = Label(zhuye, textvariable=var)
textLabel.pack(side=LEFT)
a = open("UI.txt")
b = a.read()
c = int(b)
if c == 1:
photo = PhotoImage(file="小甲鱼.GIF")
imgLabel = Label(root, image=photo)
imgLabel.pack(side=RIGHT)
else:
photo = PhotoImage(file="小甲鱼2.GIF")
imgLabel = Label(root, image=photo)
imgLabel.pack(side=RIGHT)
sleep = Button(zhuye, text="睡觉", command=sleep)
sleep.pack()
eat = Button(zhuye, text="吃饭", command=eat)
eat.pack()
work = Button(zhuye, text="上班", command=work)
work.pack()
study = Button(zhuye, text="学习Python", command=study)
study.pack()
play = Button(zhuye, text="玩游戏", command=play)
play.pack()
zhuye.pack(padx=200, pady=170)
go.pack(padx=10, pady=10)
mainloop()
elif choices == "游戏规则":
msg = "游戏规则"
title = "小甲鱼"
choices = ["游戏设定", "主页功能"]
c = g.choicebox(msg, title, choices)
if c == "游戏设定":
g.msgbox("小甲鱼现在由你来控制。设定如下:\n1.点击按钮来控制小甲鱼做什么\n2.如果寿命、疲惫、食物、金钱其一达到了最低值或最高值,游戏结束。")
else:
g.msgbox("点击“开始游戏”即可开始,点击“历史记录”查看历史记录,您还可以设置小甲鱼。")
elif choices == "历史成绩":
a = open('fen.txt')
b = a.read()
g.msgbox(b)
elif choices == "设置小甲鱼":
msg = "小甲鱼?"
title = "设置"
choices = ["1号", "2号"]
choices = g.choicebox(msg, title, choices)
if choices == "1号":
with open('UI.txt', 'w') as f:
f.write("1")
g.msgbox("设置成功!")
else:
with open('UI.txt', 'w') as f:
f.write("2")
g.msgbox("设置成功!")
elif choices == "退出":
exit(0)