一段有点bug的游戏

``废话少说,亮代码。`
monster=(‘小火龙’,‘火恐龙’,‘喷火龙’)
monster1={‘名字’:‘小火龙’,‘属性’:‘火’,‘生命’:‘C’,‘攻击’:‘C’,‘防御’:‘C’,‘速度’:‘D’,‘技能1’:‘小火球’,‘技能2’:‘撕咬’,‘技能3’:‘龙盾’}
dishu={‘名字’:‘地鼠’,‘属性’:‘土’,‘等级’:2,‘生命’:99999,‘攻击’:100000,‘防御’:989,‘速度’:100,‘技能1’:‘碎石’,‘技能2’:‘撞击’,‘技能3’:‘硬化’}
qwe=0
pokemon=[{‘名字’:‘无’,‘属性’:‘无’,‘等级’:0,‘生命’:0,‘攻击’:0,‘防御’:0,‘速度’:0,‘技能1’:‘无’,‘技能2’:‘无’,‘技能3’:‘无’},
{‘名字’:‘无’,‘属性’:‘无’,‘等级’:0,‘生命’:0,‘攻击’:0,‘防御’:0,‘速度’:0,‘技能1’:‘无’,‘技能2’:‘无’,‘技能3’:‘无’},
{‘名字’:‘无’,‘属性’:‘无’,‘等级’:0,‘生命’:0,‘攻击’:0,‘防御’:0,‘速度’:0,‘技能1’:‘无’,‘技能2’:‘无’,‘技能3’:‘无’},
{‘名字’:‘无’,‘属性’:‘无’,‘等级’:0,‘生命’:0,‘攻击’:0,‘防御’:0,‘速度’:0,‘技能1’:‘无’,‘技能2’:‘无’,‘技能3’:‘无’},
{‘名字’:‘无’,‘属性’:‘无’,‘等级’:0,‘生命’:0,‘攻击’:0,‘防御’:0,‘速度’:0,‘技能1’:‘无’,‘技能2’:‘无’,‘技能3’:‘无’},
{‘名字’:‘无’,‘属性’:‘无’,‘等级’:0,‘生命’:0,‘攻击’:0,‘防御’:0,‘速度’:0,‘技能1’:‘无’,‘技能2’:‘无’,‘技能3’:‘无’}]

MYpower={‘名字’:‘无’,‘属性’:‘无’,‘等级’:0,‘生命’:0,‘攻击’:0,‘防御’:0,‘速度’:0,‘技能1’:‘无’,‘技能2’:‘无’,‘技能3’:‘无’}
ENEMYpower={‘名字’:‘无’,‘属性’:‘无’,‘等级’:0,‘生命’:0,‘攻击’:0,‘防御’:0,‘速度’:0,‘技能1’:‘无’,‘技能2’:‘无’,‘技能3’:‘无’}

attack_skill={“撕咬”:1.8,“撞击”:1.5,“小火球”:1.5,“碎石”:1.5}
defense_buff={“龙盾”:1.3,“硬化”:1.2}
jixu=0

#导入库
import tkinter
import random
import tkinter.messagebox
import time
a=0
‘’’
print(“Loading:”,end = “”)
for i in range(30):
print(".",end = ‘’,flush = True)
time.sleep(0.5)
print("\n\n\nPlease wait:",end = “”)
for i in range(32):
print(".",end = ‘’,flush = True)
time.sleep(0.5)
‘’’
#创建主窗口
start=tkinter.Tk()
#设置标题
start.title(‘Start’)
#设置主窗口的大小和位置
start.geometry(‘300x150+100+10’)
#不允许改变窗口大小
start.resizable(False,False)
#设置最大窗口大小
start.maxsize(1200,800)
#设置最小窗口大小
start.minsize(1200,800)
def func5():
start.destroy()
def func6():
global a
start.destroy()
a=1
def keep():
global a
global jixu
start.destroy()
a=1
jixu=1

new=tkinter.Button(start,text=’’‘new
‘’’,command=func5,width=5,height=2)
#显示
new.place(x=150,y=180)

keep=tkinter.Button(start,text=’’‘keep
‘’’,command=keep,width=5,height=2)
#显示
keep.place(x=110,y=180)

EXIT=tkinter.Button(start,text=’’‘EXIT
‘’’,command=func6,width=5,height=2)
#显示
EXIT.place(x=190,y=180)

start.mainloop()

#创建主窗口
nothing=tkinter.Tk()
#设置标题
nothing.title(‘剧情’)
#设置主窗口的大小和位置
nothing.geometry(‘300x150+100+10’)
#不允许改变窗口大小
nothing.resizable(False,False)
#设置最大窗口大小
nothing.maxsize(1200,800)
#设置最小窗口大小
nothing.minsize(1200,800)
step=0

def func7():
global step
plotl=(’ 在这里,你能捕捉各种精灵(Pikaqui!)\n’,‘呵,是皮卡丘!\n’,
‘你会降生在任意地方。加油!’)
xs.set(plotl[step])
step=step+1
if step==3:
nothing.destroy()

xs=tkinter.Variable()
pp=tkinter.Label(nothing,textvariable=xs,bg=‘yellow’,fg=‘black’,font=(‘宋体’,10),width=300,height=30,wraplength=100,justify=‘left’,anchor=‘n’)
pp.place(x=-480,y=0)
xs.set(‘Welcome to the ITCpokmen.’)

nexts=tkinter.Button(nothing,text=’’‘next
‘’’,command=func7,width=5,height=2)
nexts.place(x=480,y=480)

if a==1:
nothing.destroy()

nothing.mainloop()

#创建主窗口
m=tkinter.Tk()
#设置标题
m.title(‘pokmen’)
#设置主窗口的大小和位置
m.geometry(‘1200x800+100+10’)
#不允许改变窗口大小
m.resizable(False,False)

n=tkinter.Variable()
p=tkinter.Label(m,textvariable=xs,bg=‘yellow’,fg=‘black’,font=(‘宋体’,10),width=300,height=30,wraplength=100,justify=‘left’,anchor=‘n’)
p.place(x=480,y=0)
n.set(‘print your name:’)
name=’’
e=tkinter.Variable()
entry=tkinter.Entry(m,textvariable=e)
e.set(“李狗蛋”)
entry.pack()

def l():
global name
name=e.get()
m.destroy()
s=tkinter.Button(m,text=’’‘over
‘’’,command=l,width=5,height=2)
s.pack(side=‘bottom’)

if a==1:
m.destroy()

m.mainloop()

#创建主窗口
ITCPOKMEN=tkinter.Tk()
#设置标题
ITCPOKMEN.title(‘pokmen’)
#设置主窗口的大小和位置
ITCPOKMEN.geometry(‘300x150+100+10’)
#不允许改变窗口大小
ITCPOKMEN.resizable(False,False)
#设置最大窗口大小
ITCPOKMEN.maxsize(1200,800)
#设置最小窗口大小
ITCPOKMEN.minsize(1200,800)

##################################################导航区函数###########################################################
Map=[[‘雪山镇’,‘白雪山’,‘天空之城’,‘诺亚高原’,‘真新镇’],
[‘贝尔湖’,‘贝尔湖畔’,‘1号公路’,‘诺兰平原’,‘无尽矿脉’],
[‘罪恶之都’,‘2号公路’,‘ITC城’,‘3号公路’,‘恐怖地牢’],
[‘荆棘沼泽’,‘科研中心’,‘4号公路’,‘天陨盆地’,‘哈哈沙漠’],
[‘神农镇’,‘迷雾森林’,‘发电站’,‘火焰山’,‘火山镇’]]

x=0
y=0
qqq=0
def qqqq():
global qqq
if qqq0:
tkinter.messagebox.showinfo(‘提示’,‘当前无战斗、事件。’)
if qqq
1:
tkinter.messagebox.showinfo(‘提示’,‘请先完成当前事件。’)
if qqq==2:
tkinter.messagebox.showinfo(‘提示’,‘请先完成当前战斗。’)

def 定位():
global x
global y
global qwe
global qqq
qwe=qwe+1
零.set(‘当前位置为:’+Map[y//100][x//100]+’\n当前坐标:’+‘x=’+str(x)+‘y=’+str(y))
if qwe5:
AB=tkinter.messagebox.askyesno(‘事件’,‘有一只教授让你用背包地精灵击败追他的钻地鼠。是否帮助?’)
if AB
True:
L2.set(‘请选择精灵球:\nA 小火龙 B 杰尼龟 C 妙蛙种子’)
A1.set(‘小火龙’)
A2.set(‘杰尼龟’)
A3.set(‘妙蛙种子’)
qqq=1

    else:
        tkinter.messagebox.showinfo('游戏结束了。')
        ITCPOKMEN.destroy()

def func():
global x
global y
global qqq
if qqq==0:
if x>0:
x=x-1
else:
tkinter.messagebox.showinfo(‘1’,‘您已到达最西边,无法前进。’)
定位()
else:
qqqq()

def func1():
global x
global y
global qqq
if qqq==0:
if y>0:
y=y-1
else :
tkinter.messagebox.showinfo(‘1’,‘您已到达最北边,无法前进。’)
定位()
else:
qqqq()

def func2():
global x
global y
global qqq
if qqq==0:
if y<499:
y=y+1
else:
tkinter.messagebox.showinfo(‘1’,‘您已到达最南边,无法前进。’)
定位()
else:
qqqq()

def func3():
global x
global y
global qqq
if qqq==0:
if x<499:
x=x+1
else:
tkinter.messagebox.showinfo(‘1’,‘您已到达最东边,无法前进。’)
定位()
else:
qqqq()

##################################################事件区函数##################################
def twoclean():
L2.set(’(当前无事件处理)’)
A1.set(‘选项一’)
A2.set(‘选项二’)
A3.set(‘选项三’)

def fight(grade):
global pokemon
global MYpower
global ENEMYpower
global qqq
AB=False
while ABFalse:
for i in range(6):
if pokemon[i][‘名字’]!=‘无’:
AB=tkinter.messagebox.askyesno(‘这位猪,您好!’,‘是否选择’+pokemon[i][‘名字’]+‘这只猪进行战斗??????!’)
if AB
True:
MYpower=pokemon[i]
ENEMYpower=dishu

                L4.set(pokemon[i]['名字']+',就决定是你了!!!!!!!!!!!!!!!!!')
                C1.set(MYpower['技能1'])
                C2.set(MYpower['技能2'])
                C3.set(MYpower['技能3'])
                qqq=2
                break

def fight_over():
global qqq
L4.set(‘暂无战斗发生。’)
C1.set(‘技能1’)
C2.set(‘技能2’)
C3.set(‘技能3’)
qqq=0

def fighting(myskill):
global MYpower
global ENEMYpower
global attack_skill
global defense_buff
fff=’’
if MYpower[myskill] in attack_skill:
ENEMYpower[‘生命’]=ENEMYpower[‘生命’]-MYpower[‘攻击’]*attack_skill[MYpower[myskill]]
fff=MYpower[‘名字’]+‘使用’+MYpower[myskill]+’!\n’
L4.set(fff+‘我方血量:’+str(MYpower[‘生命’])+’\n敌方血量:’+str(ENEMYpower[‘生命’]))
elif MYpower[myskill] in defense_buff:
MYpower[‘防御’]=MYpower[‘防御’]*defense_buff[MYpower[myskill]]
fff=MYpower[‘名字’]+‘使用’+MYpower[myskill]+’!/n’
L4.set(fff+‘我方血量:’+str(MYpower[‘生命’])+’\n敌方血量:’+str(ENEMYpower[‘生命’]))
if ENEMYpower[‘生命’]<=0:
tkinter.messagebox.showinfo(‘胜利!’,‘你击败了’+ENEMYpower[‘名字’]+’!’)
fight_over()
return
MYpower[‘生命’]=MYpower[‘生命’]-ENEMYpower[‘攻击’]*attack_skill[‘碎石’]
fff=fff+ENEMYpower[‘名字’]+‘使用碎石!/n’
L4.set(fff+‘我方血量:’+str(MYpower[‘生命’])+’\n敌方血量:’+str(ENEMYpower[‘生命’]))
if MYpower[‘生命’]<=0:
tkinter.messagebox.showinfo(‘失败!’,‘你被击败了!’)
fight_over()
return

def aone():
global qqq
global qwe
if qqq1:
if qwe
5:
tkinter.messagebox.showinfo(‘Great!!’,‘获得小火龙。’)
B1.set(‘小火龙’)
pokemon[0]={‘名字’:‘小火龙’,‘属性’:‘火’,‘等级’:9999,‘生命’:999999999999999999,‘攻击’:100,‘防御’:-1,‘速度’:99999999999999,‘技能1’:‘小火球’,‘技能2’:‘撕咬’,‘技能3’:‘龙盾’}
L3.set(str(pokemon[0]))
qwe=qwe+1
twoclean()
fight(2)
qqq=2

else:
    qqqq()

def aatwo():
global qqq
global qwe
if qqq1:
if qwe
5:
tkinter.messagebox.showinfo(‘Great!!’,‘获得杰尼龟。’)
B1.set(‘杰尼龟’)
pokemon[0]={‘名字’:‘杰尼龟’,‘属性’:‘水’,‘等级’:20,‘生命’:999,‘攻击’:543,‘防御’:187,‘速度’:9999,‘技能1’:‘小火球’,‘技能2’:‘撕咬’,‘技能3’:‘龙盾’}
L3.set(str(pokemon[0]))
qwe=qwe+1
twoclean()
fight(2)
qqq=2

else:
    qqqq()

def aaathree():
global qqq
global qwe
if qwe5:
tkinter.messagebox.showinfo(‘Great!!’,‘获得妙蛙种子。’)
B1.set(‘妙蛙种子’)
pokemon[0]={‘名字’:‘妙蛙种子’,‘属性’:‘草’,‘等级’:5,‘生命’:9999,‘攻击’:100,‘防御’:999999,‘速度’:9999999999,‘技能1’:‘小火球’,‘技能2’:‘撕咬’,‘技能3’:‘龙盾’}
L3.set(str(pokemon[0]))
qwe=qwe+1
twoclean()
fight(2)
qqq=2
if qqq
1:
pass
else:
qqqq()

##############################################################################精灵区函数################################################################################################
def ss1():
L3.set(str(pokemon[0]))

def ss2():
L3.set(str(pokemon[1]))
def ss3():
L3.set(str(pokemon[2]))
def ss4():
L3.set(str(pokemon[3]))
def ss5():
L3.set(str(pokemon[4]))
def ss6():
L3.set(str(pokemon[5]))

零=tkinter.Variable()
小小哈=tkinter.Label(ITCPOKMEN,textvariable=零,
bg=‘white’,fg=‘black’,font=(‘宋体’,10),width=30,height=6,wraplength=200,justify=‘left’,anchor=‘n’)
#显示
小小哈.place(x=50,y=50)
零.set(’’)

t=tkinter.Button(ITCPOKMEN,text=’’‘向北
‘’’,command=func1,width=5,height=2)
#显示
t.place(x=100,y=140)

t=tkinter.Button(ITCPOKMEN,text=’’‘向南
‘’’,command=func2,width=5,height=2)
#显示
t.place(x=50,y=140)

t=tkinter.Button(ITCPOKMEN,text=’’‘向东
‘’’,command=func3,width=5,height=2)
#显示
t.place(x=150,y=140)
t=tkinter.Button(ITCPOKMEN,text=’’‘向西
‘’’,command=func,width=5,height=2)
#显示
t.place(x=200,y=140)

##################################################################################战斗区函数#########################################################################################
def power1():
if qqq2:
fighting(‘技能1’)
else:
qqqq()
def power2():
if qqq
2:
fighting(‘技能2’)
else:
qqqq()
def power3():
if qqq==2:
fighting(‘技能3’)
else:
qqqq()

#####################################################################################菜单函数###############################################################
def save():
global qqq
if qqq==0:
fo=open(‘save.txt’,‘w+’)
Data=name+’ ‘+str(x)+’ ‘+str(y)+’ ‘+str(qwe)+’ '+str(pokemon)
fo.write(Data)
fo.close()
tkinter.messagebox.showinfo(‘提示’,‘保存成功!’)
else:
qqqq()
def exit2():
ITCPOKMEN.destroy()

if jixu1:
a=0
fo=open(‘save.txt’,‘r+’)
line=fo.read()
fo.close()
j=0
nn=[’’,’’,’’,’’,’’]
for i in range(len(line)):
if line[i]
’ ‘and j!=4:
j=j+1
continue
if line[i]’]'or line[i]’[’:
continue
nn[j]=nn[j]+line[i]
name=nn[0]
x=int(nn[1])
y=int(nn[2])
qwe=int(nn[3])
pokemon=nn[4].split(’},’)
for i in range(5):
pokemon[i]=eval(str(pokemon[i])+’}’)
pokemon[5]=eval(str(pokemon[5]))
tkinter.messagebox.showinfo(‘提示’,‘读取存档成功!’)

#################################################事件区###########################################################
L2=tkinter.Variable()
l2=tkinter.Label(ITCPOKMEN,textvariable=L2,
bg=‘brown’,fg=‘white’,font=(‘宋体’,10),width=30,height=6,wraplength=200,justify=‘left’,anchor=‘n’)
#显示
l2.place(x=350,y=50)
L2.set(‘Nothing’)
###按钮###
A1=tkinter.Variable()
a1=tkinter.Button(ITCPOKMEN,textvariable=A1,
command=aone,width=5,height=2)
#显示
a1.place(x=350,y=140)
A1.set(‘选项一’)

A2=tkinter.Variable()
a2=tkinter.Button(ITCPOKMEN,textvariable=A2,
command=aatwo,width=5,height=2)
#显示
a2.place(x=425,y=140)
A2.set(‘选项二’)

A3=tkinter.Variable()
a3=tkinter.Button(ITCPOKMEN,textvariable=A3,
command=aaathree,width=5,height=2)
#显示
a3.place(x=500,y=140)
A3.set(‘选项三’)

##################################################精灵区###########################################################
L3=tkinter.Variable()
l3=tkinter.Label(ITCPOKMEN,textvariable=L3,
bg=‘black’,fg=‘blue’,font=(‘宋体’,10),width=30,height=6,wraplength=200,justify=‘left’,anchor=‘n’)
#显示
l3.place(x=110,y=300)
L3.set(‘Nothing’)

B1=tkinter.Variable()
b1=tkinter.Button(ITCPOKMEN,textvariable=B1,
command=ss1,width=5,height=2)
#显示
b1.place(x=10,y=210)
B1.set(pokemon[0][‘名字’])

B2=tkinter.Variable()
b2=tkinter.Button(ITCPOKMEN,textvariable=B2,
command=ss2,width=5,height=2)
#显示
b2.place(x=10,y=240)
B2.set(‘无’)

B3=tkinter.Variable()
b3=tkinter.Button(ITCPOKMEN,textvariable=B3,
command=ss3,width=5,height=2)
#显示
b3.place(x=10,y=270)
B3.set(‘无’)

B4=tkinter.Variable()
b4=tkinter.Button(ITCPOKMEN,textvariable=B4,
command=ss4,width=5,height=2)
#显示
b4.place(x=10,y=300)
B4.set(‘无’)

B5=tkinter.Variable()
b5=tkinter.Button(ITCPOKMEN,textvariable=B5,
command=ss5,width=5,height=2)
#显示
b5.place(x=10,y=330)
B5.set(‘无’)

B6=tkinter.Variable()
b6=tkinter.Button(ITCPOKMEN,textvariable=B6,
command=ss6,width=5,height=2)
#显示
b6.place(x=10,y=360)
B6.set(‘无’)

##################################################################################战斗区#########################################################################################

L4=tkinter.Variable()
l4=tkinter.Label(ITCPOKMEN,textvariable=L4,
bg=‘pink’,fg=‘orange’,font=(‘宋体’,10),width=30,height=6,wraplength=200,justify=‘left’,anchor=‘n’)
#显示
l4.place(x=350,y=250)
L4.set(‘Nothing’)
###按钮###
C1=tkinter.Variable()
c1=tkinter.Button(ITCPOKMEN,textvariable=C1,
command=power1,width=5,height=2)
#显示
c1.place(x=350,y=350)
C1.set(‘技能一’)

C2=tkinter.Variable()
c2=tkinter.Button(ITCPOKMEN,textvariable=C2,
command=power2,width=5,height=2)
#显示
c2.place(x=425,y=350)
C2.set(‘技能二’)

C3=tkinter.Variable()
c3=tkinter.Button(ITCPOKMEN,textvariable=C3,
command=power3,width=5,height=2)
#显示
c3.place(x=500,y=350)
C3.set(‘技能三’)

##########################################################################

baocun=tkinter.Button(ITCPOKMEN,text=‘保存’,command=save,width=8,height=1)
baocun.place(x=600,y=50)
tuichu2=tkinter.Button(ITCPOKMEN,text=‘退出’,command=exit2,width=8,height=1)
tuichu2.place(x=600,y=100)

##########################################################################################################################################################################################################
if a==1:
ITCPOKMEN.destroy()
ITCPOKMEN.mainloop()

`
好了,这里就是。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值