当前位置: 首页>后端>正文

pythonista自制游戏模型源码,运行需要把相应图片上传,和两个pyui文件上传,四五年前写的

from scene import *

import sound

import random

import math

import os

from math import sin, cos, pi

import pickle

import ui

A = Action

namelist=['emj:Ambulance','emj:Imp','emj:Direct_Hit','emj:Anger_Symbol']

def save_obj(obj, name ):

with open(name + '.pkl', 'wb') as f:

pickle.dump(obj, f, pickle.HIGHEST_PROTOCOL)

def load_obj(name ):

try:

with open(name + '.pkl', 'rb') as f:

return pickle.load(f)

except EOFError:

return None

print('return')

if not os.path.exists('firstopen.txt'):

file1=open('firstopen.txt','w')

file2=open('money1.txt','w')

file3=open('money2.txt','w')

f1money=0

f2money=0

file4=open('popnamelist1.txt','w')

file5=open('popnamelist2.txt','w')

popnamelist1=[]

popnamelist2=[]

file6=open('levelupyes1.pkl','wb')

file7=open('levelupyes2.pkl','wb')

levelupyes1={}

levelupyes2={}

file8=open('level1.pkl','wb')

file9=open('level2.pkl','wb')

level1={}

level2={}

file10=open('usedcount1.pkl','wb')

file11=open('usedcount.pkl','wb')

usedcount1={}

usedcount2={}

file12=open('hitarmorlifeplus1.txt','w')

file13=open('hitarmorlifeplus2.txt','w')

hit1=1

armor1=0

lifeplus1=0

hit2=1

armor2=0

lifeplus2=0

file14=open('winlosenum.txt','w')

winnum=0

losenum=0

timelapfor1=0.5

timelapfor2=0.5

else:

#file1=open('firstopen.txt','r')

#str1=file1.readline()

#str1=str1.strip(',')

#if int(str1)==1:

#print('ok')

file2=open('money1.txt','r')

if os.path.getsize('money1.txt')==0:

f1money=0

else:

str2=file2.readline()

str2=str2.strip(',')

f1money=float(str2)

file3=open('money2.txt','r')

if os.path.getsize('money2.txt')==0:

f2money=0

else:

str3=file3.readline()

str3=str3.strip(',')

f2money=float(str3)

file4=open('popnamelist1.txt','r')

if os.path.getsize('popnamelist1.txt')==0:

popnamelist1=[]

else:

list4=file4.readlines()

for i in range(0,len(list4)):

list4[i]=list4[i].rstrip('\n')

popnamelist1=list4

file5=open('popnamelist2.txt','r')

if os.path.getsize('popnamelist2.txt')==0:

popnamelist2=[]

else:

list5=file5.readlines()

for i in range(0,len(list5)):

list5[i]=list5[i].rstrip('\n')

popnamelist2=list5

file12=open('hitarmorlifeplus1.txt','r')

if os.path.getsize('hitarmorlifeplus1.txt')==0:

hit1=1

armor1=0

lifeplus1=0

timelapfor1=0.5

else:

strh1=file12.readline()

strh1=strh1.rstrip('\n')

stra1=file12.readline()

stra1=stra1.rstrip('\n')

strl1=file12.readline()

strl1=strl1.rstrip('\n')

strt1=file12.readline()

strt1=strt1.rstrip('\n')

hit1=float(strh1)

armor1=float(stra1)

lifeplus1=float(strl1)

timelapfor1=float(strt1)

file13=open('hitarmorlifeplus2.txt','r')

if os.path.getsize('hitarmorlifeplus2.txt')==0:

hit2=1

armor2=0

lifeplus2=0

timelapfor2=0.5

else:

strh2=file13.readline()

strh2=strh2.rstrip('\n')

stra2=file13.readline()

stra2=stra2.rstrip('\n')

strl2=file13.readline()

strl2=strl2.rstrip('\n')

strt2=file13.readline()

strt2=strt2.rstrip('\n')

hit2=float(strh2)

armor2=float(stra2)

lifeplus2=float(strl2)

timelapfor2=float(strt2)

file14=open('winlosenum.txt','r')

if os.path.getsize('winlosenum.txt')==0:

winnum=0

losenum=0

else:

strw=file14.readline()

strw=strw.rstrip('\n')

strl=file14.readline()

strl=strl.rstrip('\n')

winnum=int(strw)

losenum=int(strl)

levelupyes1=load_obj('levelupyes1')

levelupyes2=load_obj('levelupyes2')

level1=load_obj('level1')

level2=load_obj('level2')

usedcount1=load_obj('usedcount1')

usedcount2=load_obj('usedcount2')

popnamelist1copy=[]

popnamelist2copy=[]

lnum2=0

silence1=False

silence2=False

class maze(SpriteNode):

def __init__(self,*args, **kwargs):

SpriteNode.__init__(self, 'emj:Alien_Monster',*args, **kwargs)

self.wtotalnum=8

self.htotalnum=8

self.dm=100

self.diameter=self.dm

self.radius=self.diameter/2

self.bgpic=Texture('texture2.png')

self.bgpic.anchor_point=(0,0)

self.bgpic.position=(0,0)

self.wnum=random.randint(1,self.wtotalnum)

self.hnum=random.randint(1,self.htotalnum)

self.blend_mode=BLEND_MULTIPLY

self.position=(self.wnum*self.diameter-self.diameter/2,self.hnum*self.diameter-self.diameter/2)

self.rotatenum=0

self.movable=False

self.direction=0

def settexture(self,img):

self.texture=Texture(img)

def setwhnum(self,wnum,hnum):

self.wnum=wnum

self.hnum=hnum

def setpos(self):

self.position=(self.wnum*self.diameter-self.diameter/2,self.hnum*self.diameter-self.diameter/2)

class fish(SpriteNode):

def __init__(self,*args, **kwargs):

SpriteNode.__init__(self, 'emj:Blowfish',*args, **kwargs)

self.wtotalnum=8

self.htotalnum=8

self.dm=100

self.diameter=self.dm

self.radius=self.diameter/2

self.bgpic=Texture('texture1.png')

self.bgpic.anchor_point=(0,0)

self.bgpic.position=(0,0)

self.wnum=random.randint(1,self.wtotalnum)

self.hnum=random.randint(1,self.htotalnum)

self.blend_mode=BLEND_MULTIPLY

self.position=(self.wnum*self.diameter-self.diameter/2,self.hnum*self.diameter-self.diameter/2)

self.rotatenum=0

self.movable=False

self.mlist=[]

self.shootgetnum=random.randint(1,3)

self.shoottotalnum=0

self.money=0

self.mid()

self.up()

self.down()

self.left()

self.right()

self.circle1=SpriteNode('circle1.png')

#self.circle1.run_action(A.scale_to(0.5,0))

self.circle1.position=self.parent.position

self.circle1.blend_mode=BLEND_MULTIPLY

def drawcircle(self):

'''

circle=ui.Path.oval(0,0,200,200)

#circle.fill()

circle.stroke()

circle.line_width = 5

circle.close()

self.circle1 = ShapeNode(circle)

self.circle1.position=self.parent.position

self.circle1.stroke_color = 'blue'

#self.circle1.alpha = 0.5

#self.circle1.z_position = 0.8

#self.circle1.blend_mode=BLEND_MULTIPLY

self.add_child(self.circle1)'''

self.add_child(self.circle1)

def endcircle(self):

self.circle1.remove_from_parent()

def settexture(self,img):

self.texture=Texture(img)

def mid(self):

wnummid=self.wnum

hnummid=self.hnum

self.midpic=self.bgpic.subtexture(Rect((wnummid-1)*self.diameter,(hnummid-1)*self.diameter,1/self.wtotalnum,1/self.htotalnum))

intnum=random.randint(1,3)

self.midpic.positionx=wnummid*self.diameter-self.radius

self.midpic.positiony=hnummid*self.diameter-self.radius

if intnum==1:

self.midpic.hitboxh=Rect(self.midpic.positionx-self.radius-1,self.midpic.positiony-5,self.diameter-2,10)

self.midpic.hitboxv=Rect(self.midpic.positionx-0.5,self.midpic.positiony-0.5,1,1)

if intnum==2:

self.midpic.hitboxh=Rect(self.midpic.positionx-0.5,self.midpic.positiony-0.5,1,1)

self.midpic.hitboxv=Rect(self.midpic.positionx-5,self.midpic.positiony-self.radius-1,10,self.diameter+2)

if intnum==3:

self.midpic.hitboxh=Rect(self.midpic.positionx-self.radius-1,self.midpic.positiony-5,self.diameter+2,10)

self.midpic.hitboxv=Rect(self.midpic.positionx-5,self.midpic.positiony-self.radius-1,10,self.diameter+2)

def up(self):

wnumup=self.wnum

hnumup=self.hnum+1

self.uppic=self.bgpic.subtexture(Rect((wnumup-1)*self.diameter,(hnumup-1)*self.diameter,1/self.wtotalnum,1/self.htotalnum))

self.uppic.positionx=wnumup*self.diameter-self.radius

self.uppic.positiony=hnumup*self.diameter-self.radius

self.setbbox(self.uppic)

def down(self):

wnumdown=self.wnum

hnumdown=self.hnum-1

self.downpic=self.bgpic.subtexture(Rect((wnumdown-1)*self.diameter,(hnumdown-1)*self.diameter,1/self.wtotalnum,1/self.htotalnum))

self.downpic.positionx=wnumdown*self.diameter-self.radius

self.downpic.positiony=hnumdown*self.diameter-self.radius

self.setbbox(self.downpic)

def left(self):

wnumleft=self.wnum-1

hnumleft=self.hnum

self.leftpic=self.bgpic.subtexture(Rect((wnumleft-1)*self.diameter,(hnumleft-1)*self.diameter,1/self.wtotalnum,1/self.htotalnum))

self.leftpic.positionx=wnumleft*self.diameter-self.radius

self.leftpic.positiony=hnumleft*self.diameter-self.radius

self.setbbox(self.leftpic)

def right(self):

wnumright=self.wnum+1

hnumright=self.hnum

self.rightpic=self.bgpic.subtexture(Rect((wnumright-1)*self.diameter,(hnumright-1)*self.diameter,1/self.wtotalnum,1/self.htotalnum))

self.rightpic.positionx=wnumright*self.diameter-self.radius

self.rightpic.positiony=hnumright*self.diameter-self.radius

self.setbbox(self.rightpic)

def setbbox(self,setpic):

intnum=random.randint(1,11)

if intnum==1:

setpic.hitboxh=Rect(setpic.positionx-self.radius-1,setpic.positiony-5,self.diameter+2,10)

setpic.hitboxv=Rect(setpic.positionx-5,setpic.positiony,10,self.radius+1)

if intnum==2:

setpic.hitboxh=Rect(setpic.positionx-self.radius-1,setpic.positiony-5,self.radius+1,10)

setpic.hitboxv=Rect(setpic.positionx-5,setpic.positiony-self.radius-1,5,self.diameter+2)

if intnum==3:

setpic.hitboxh=Rect(setpic.positionx-self.radius-1,setpic.positiony-5,self.diameter+2,10)

setpic.hitboxv=Rect(setpic.positionx-5,setpic.positiony-self.radius-1,10,self.radius+1)

if intnum==4:

setpic.hitboxh=Rect(setpic.positionx,setpic.positiony-5,self.radius+1,10)

setpic.hitboxv=Rect(setpic.positionx-5,setpic.positiony-self.radius-1,10,self.diameter+2)

if intnum==5:

setpic.hitboxh=Rect(setpic.positionx-self.radius-1,setpic.positiony-5,self.radius+1,10)

setpic.hitboxv=Rect(setpic.positionx-5,setpic.positiony,5,self.radius+1)

if intnum==6:

setpic.hitboxh=Rect(setpic.positionx-self.radius-1,setpic.positiony-5,self.radius+1,10)

setpic.hitboxv=Rect(setpic.positionx-5,setpic.positiony-self.radius-1,10,self.radius+1)

if intnum==7:

setpic.hitboxh=Rect(setpic.positionx,setpic.positiony-5,self.radius+1,10)

setpic.hitboxv=Rect(setpic.positionx-5,setpic.positiony-self.radius-1,10,self.radius+1)

if intnum==8:

setpic.hitboxh=Rect(setpic.positionx,setpic.positiony-5,self.radius+1,10)

setpic.hitboxv=Rect(setpic.positionx-5,setpic.positiony,5,self.radius+1)

if intnum==9:

setpic.hitboxh=Rect(setpic.positionx-self.radius-1,setpic.positiony-5,self.diameter+2,10)

setpic.hitboxv=Rect(setpic.positionx-0.5,setpic.positiony-0.5,1,1)

if intnum==10:

setpic.hitboxh=Rect(setpic.positionx-0.5,setpic.positiony-0.5,1,1)

setpic.hitboxv=Rect(setpic.positionx-5,setpic.positiony-self.radius-1,10,self.diameter+2)

if intnum==11:

setpic.hitboxh=Rect(setpic.positionx-self.radius-1,setpic.positiony-5,self.diameter+2,10)

setpic.hitboxv=Rect(setpic.positionx-5,setpic.positiony-self.radius-1,10,self.diameter+2)

def rotate(self,pausenum):

ax=self.midpic.positionx

ay=self.midpic.positiony

self.new_hitboxh=Rect(ax+self.midpic.hitboxv.y-ay,ay+self.midpic.hitboxv.x-ax,self.midpic.hitboxv.h,self.midpic.hitboxv.w)

self.new_hitboxv=Rect(ax+self.midpic.hitboxh.y-ay,ay+self.midpic.hitboxh.x-ax,self.midpic.hitboxh.h,self.midpic.hitboxh.w)

self.midpic.hitboxh=self.new_hitboxh

self.midpic.hitboxv=self.new_hitboxv

self.rotatenum+=1

if self.rotatenum==pausenum:

self.mid()

self.up()

self.down()

self.left()

self.right()

self.rotatenum=0

def move(self):

self.piclist=[]

picmovelist=[]

self.makelist(self.piclist)

for pic in self.piclist:

if pic is not None and self.midpic is not None and pic.hitboxh.intersects(self.midpic.hitboxh):

picmovelist.append(pic)

self.movable=True

elif pic is not None and self.midpic is not None and pic.hitboxv.intersects(self.midpic.hitboxv):

picmovelist.append(pic)

self.movable=True

if self.movable:

picmove=random.choice(picmovelist)

self.px,self.py=picmove.positionx,picmove.positiony

self.wnum=self.px//self.diameter+1

self.hnum=self.py//self.diameter+1

self.position=(self.wnum*self.diameter-self.diameter/2,self.hnum*self.diameter-self.diameter/2)

self.movable=False

self.rotatenum=0

self.mid()

self.up()

self.down()

self.left()

self.right()

def makelist(self,li):

if self.wnum==1 and self.hnum==1:

li.append(self.uppic)

li.append(self.rightpic)

elif self.wnum==1 and self.hnum==self.htotalnum:

li.append(self.downpic)

li.append(self.rightpic)

elif self.hnum==self.htotalnum and self.wnum==self.wtotalnum:

li.append(self.downpic)

li.append(self.leftpic)

elif self.hnum==1 and self.wnum==self.wtotalnum:

li.append(self.uppic)

li.append(self.leftpic)

elif self.wnum==1:

li.append(self.uppic)

li.append(self.downpic)

li.append(self.rightpic)

elif self.wnum==self.wtotalnum:

li.append(self.uppic)

li.append(self.downpic)

li.append(self.leftpic)

elif self.hnum==1:

li.append(self.uppic)

li.append(self.leftpic)

li.append(self.rightpic)

elif self.hnum==self.htotalnum:

li.append(self.downpic)

li.append(self.rightpic)

li.append(self.leftpic)

else:

li.append(self.uppic)

li.append(self.downpic)

li.append(self.rightpic)

li.append(self.leftpic)

class MyScene1 (Scene):

def setup(self):

self.wtotalnum=8

self.htotalnum=8

self.dm=100

self.diameter=self.dm

self.radius=self.diameter/2

self.bgpic=Texture('texture1.png')

self.bgpic.anchor_point=(0,0)

self.bgpic.position=(0,0)

#self.bgpic.size=(self.wtotalnum*self.dm,self.htotalnum*self.dm)

#self.add_child(self.bgpic)

#self.mlist=[]

self.fishlist=[]

self.ground=SpriteNode('sea.png')

self.ground.blend_mode=BLEND_NORMAL

self.ground.anchor_point=(0,0)

self.ground.position=(0,0)

self.ground.size=(self.wtotalnum*self.dm,self.htotalnum*self.dm)

#self.ground.size=self.bgpic.size

self.add_child(self.ground)

self.f1=fish(parent=self)

self.f1.settexture('emj:Baby_Chick_2')

self.f1.blend_mode=BLEND_NORMAL

self.f2=fish(parent=self)

self.f2.settexture('emj:Bear_Face')

self.f2.blend_mode=BLEND_NORMAL

self.flist=[]

self.flist.append(self.f1)

self.flist.append(self.f2)

self.f1.blood=random.randint(100,120)+lifeplus1

self.f2.blood=random.randint(100,120)+lifeplus2

self.spawnfish()

self.spawn_shootnumlable1()

self.spawn_shootnumlable2()

self.spawn_moneylable1()

self.spawn_moneylable2()

self.spawn_bloodlable1()

self.spawn_bloodlable2()

self.spawn_returnlable()

self.spawn_winlable()

self.spawn_winnumlable()

self.spawn_powerup()

#self.f1.drawcircle()

def spawn_powerup(self):

self.powerup1=SpriteNode('plc:Heart')

self.powerup2=SpriteNode('plc:Heart')

self.powerup3=SpriteNode('plc:Heart')

self.powerup4=SpriteNode('plc:Heart')

self.powerup5=SpriteNode('plc:Heart')

self.powerup6=SpriteNode('plc:Heart')

self.powerup7=SpriteNode('plc:Heart')

self.powerup8=SpriteNode('plc:Heart')

self.powerup9=SpriteNode('plc:Heart')

self.powerup10=SpriteNode('plc:Heart')

self.powerup11=SpriteNode('plc:Heart')

self.powerup12=SpriteNode('plc:Heart')

m1=maze()

m1.setwhnum(3,3)

m1.setpos()

m2=maze()

m2.setwhnum(4,3)

m2.setpos()

m3=maze()

m3.setwhnum(5,3)

m3.setpos()

m4=maze()

m4.setwhnum(6,3)

m4.setpos()

m5=maze()

m5.setwhnum(3,4)

m5.setpos()

m6=maze()

m6.setwhnum(3,5)

m6.setpos()

m7=maze()

m7.setwhnum(3,6)

m7.setpos()

m8=maze()

m8.setwhnum(4,6)

m8.setpos()

m9=maze()

m9.setwhnum(5,6)

m9.setpos()

m10=maze()

m10.setwhnum(6,6)

m10.setpos()

m11=maze()

m11.setwhnum(6,5)

m11.setpos()

m12=maze()

m12.setwhnum(6,4)

m12.setpos()

self.powerup1.position=m1.position

self.add_child(self.powerup1)

self.powerup2.position=m2.position

self.add_child(self.powerup2)

self.powerup3.position=m3.position

self.add_child(self.powerup3)

self.powerup4.position=m4.position

self.add_child(self.powerup4)

self.powerup5.position=m5.position

self.add_child(self.powerup5)

self.powerup6.position=m6.position

self.add_child(self.powerup6)

self.powerup7.position=m7.position

self.add_child(self.powerup7)

self.powerup8.position=m8.position

self.add_child(self.powerup8)

self.powerup9.position=m9.position

self.add_child(self.powerup9)

self.powerup10.position=m10.position

self.add_child(self.powerup10)

self.powerup11.position=m11.position

self.add_child(self.powerup11)

self.powerup12.position=m12.position

self.add_child(self.powerup12)

self.poweruplist=[]

self.poweruplist.append(self.powerup1)

self.poweruplist.append(self.powerup2)

self.poweruplist.append(self.powerup3)

self.poweruplist.append(self.powerup4)

self.poweruplist.append(self.powerup5)

self.poweruplist.append(self.powerup6)

self.poweruplist.append(self.powerup7)

self.poweruplist.append(self.powerup8)

self.poweruplist.append(self.powerup9)

self.poweruplist.append(self.powerup10)

self.poweruplist.append(self.powerup11)

self.poweruplist.append(self.powerup12)

def check_get_powerup(self,f):

for powerup in self.poweruplist:

if f.position in powerup.frame:

self.spawn_maze_shoot(f)

powerup.remove_from_parent()

self.poweruplist.remove(powerup)

if len(self.poweruplist)<=10:

for powerup in self.poweruplist:

powerup.remove_from_parent()

self.spawn_powerup()

def movetoout(self,maze):

self.wstep=self.wtotalnum

self.hstep=self.htotalnum

dxt=self.wtotalnum*self.diameter

dyt=self.htotalnum*self.diameter

if maze.direction==0:

dx=(self.wstep-1)*self.diameter

dy=0

A0=A.move_by(-dx, -dy,dx/dxt,TIMING_EASE_OUT)

maze.direction+=1

if maze.direction==1:

dx=0

dy=(self.hstep-1)*self.diameter

A1=A.move_by(-dx,dy,dy/dyt,TIMING_EASE_OUT)

maze.direction+=1

if maze.direction==2:

dx=(self.wstep-1)*self.diameter

dy=0

A2=A.move_by(dx, -dy,dx/dxt,TIMING_EASE_OUT)

maze.direction+=1

if maze.direction==3:

self.hstep-=1

dx=0

dy=(self.hstep-1)*self.diameter

A3=A.move_by(-dx,-dy,dy/dyt,TIMING_EASE_OUT)

maze.direction+=1

self.wstep-=1

self.hstep-=1

#round2

if maze.direction==4:

dx=(self.wstep-1)*self.diameter

dy=0

B0=A.move_by(-dx, -dy,dx/dxt,TIMING_EASE_OUT)

maze.direction+=1

if maze.direction==5:

dx=0

dy=(self.hstep-1)*self.diameter

B1=A.move_by(-dx,dy,dy/dyt,TIMING_EASE_OUT)

maze.direction+=1

if maze.direction==6:

self.wstep-=1

dx=(self.wstep-1)*self.diameter

dy=0

B2=A.move_by(dx, -dy,dx/dxt,TIMING_EASE_OUT)

maze.direction+=1

if maze.direction==7:

self.hstep-=1

dx=0

dy=(self.hstep-1)*self.diameter

B3=A.move_by(-dx,-dy,dy/dyt,TIMING_EASE_OUT)

maze.direction+=1

self.wstep-=1

self.hstep-=1

#round3 same as round2

if maze.direction==8:

dx=(self.wstep-1)*self.diameter

dy=0

C0=A.move_by(-dx, -dy,dx/dxt,TIMING_EASE_OUT)

maze.direction+=1

if maze.direction==9:

dx=0

dy=(self.hstep-1)*self.diameter

C1=A.move_by(-dx,dy,dy/dyt,TIMING_EASE_OUT)

maze.direction+=1

if maze.direction==10:

self.wstep-=1

dx=(self.wstep-1)*self.diameter

dy=0

C2=A.move_by(dx, -dy,dx/dxt,TIMING_EASE_OUT)

maze.direction+=1

if maze.direction==11:

self.hstep-=1

dx=0

dy=(self.hstep-1)*self.diameter

C3=A.move_by(-dx,-dy,dy/dyt,TIMING_EASE_OUT)

maze.direction+=1

self.wstep-=1

self.hstep-=1

#round 4 same as round2

if maze.direction==12:

dx=(self.wstep-1)*self.diameter

dy=0

D0=A.move_by(-dx, -dy,dx/dxt,TIMING_EASE_OUT)

maze.direction+=1

if maze.direction==13:

dx=0

dy=(self.hstep-1)*self.diameter

D1=A.move_by(-dx,dy,dy/dyt,TIMING_EASE_OUT)

maze.direction+=1

if maze.direction==14:

self.wstep-=1

dx=(self.wstep-1)*self.diameter

dy=0

D2=A.move_by(dx, -dy,dx/dxt,TIMING_EASE_OUT)

maze.direction+=1

if maze.direction==15:

self.hstep-=1

dx=0

dy=(self.hstep-1)*self.diameter

D3=A.move_by(-dx,-dy,dy/dyt,TIMING_EASE_OUT)

maze.direction+=1

self.wstep-=1

self.hstep-=1

maze.run_action(A.sequence(D2,D1,D0,C3,C2,C1,C0,B3,B2,B1,B0,A3,A2,A1,A0,A.remove()))

def spawn_maze_shoot(self,f):

for i in range(1):

m=maze(parent=self)

m.settexture('plc:Heart')

m.blend_mode=BLEND_NORMAL

#m.setwhnum(3,3)

#m.setpos()

m.position=f.position

f.mlist.append(m)

self.movetoout(m)

def spawn_bloodlable1(self):

self.bloodlable1=LabelNode()

self.bloodlable1.text=('')

self.bloodlable1.position=200,820

self.bloodlable1.font=('Arial',30)

self.bloodlable1.color='blue'

self.add_child(self.bloodlable1)

def spawn_bloodlable2(self):

self.bloodlable2=LabelNode()

self.bloodlable2.text=('')

self.bloodlable2.position=480,820

self.bloodlable2.font=('Arial',30)

self.bloodlable2.color='blue'

self.add_child(self.bloodlable2)

def spawn_moneylable1(self):

self.moneylable1=LabelNode()

self.moneylable1.text=('')

self.moneylable1.position=200,920

self.moneylable1.font=('Arial',30)

self.moneylable1.color='yellow'

self.add_child(self.moneylable1)

def spawn_moneylable2(self):

self.moneylable2=LabelNode()

self.moneylable2.text=('')

self.moneylable2.position=520,920

self.moneylable2.font=('Arial',30)

self.moneylable2.color='yellow'

self.add_child(self.moneylable2)

def spawn_shootnumlable1(self):

self.shootnumlable1=LabelNode()

self.shootnumlable1.text=('')

self.shootnumlable1.position=200,870

self.shootnumlable1.font=('Arial',30)

self.shootnumlable1.color='green'

self.add_child(self.shootnumlable1)

def spawn_shootnumlable2(self):

self.shootnumlable2=LabelNode()

self.shootnumlable2.text=('')

self.shootnumlable2.position=480,870

self.shootnumlable2.font=('Arial',30)

self.shootnumlable2.color='green'

self.add_child(self.shootnumlable2)

def spawnfish(self):

for i in range(10):

f=fish(parent=self)

f.blend_mode=BLEND_NORMAL

self.fishlist.append(f)

def shoot(self,shooter,img,shootradius):

for i in range(40):

m = SpriteNode(img, parent=self)

m.position = shooter.position

#m.position=(0,0)

angle = random.uniform(0,pi*2)

dx, dy = cos(angle) * shootradius, sin(angle) * shootradius

#m.run_action(A.move_by(dx, dy, 0.6, TIMING_EASE_OUT))

#m.run_action(A.sequence(A.scale_to(0, 0.6), A.remove()))

m.run_action(A.sequence(A.scale_to(0.5, 0),A.move_by(dx, dy, 0.6, TIMING_EASE_OUT), A.remove()))

shooter.mlist.append(m)

def check_m_collisions(self,shooter):

global hit1,hit2,armor1,armor2

for m in shooter.mlist:

if not m.parent:

shooter.mlist.remove(m)

continue

for f in self.fishlist:

if m.position in f.frame:

f.remove_from_parent()

self.fishlist.remove(f)

shooter.shoottotalnum+=f.shootgetnum

if len(self.fishlist)<=7:

for i in range(3):

f=fish(parent=self)

f.blend_mode=BLEND_NORMAL

self.fishlist.append(f)

if shooter==self.f1:

if m.position in self.f2.frame:

self.f2.blood-=2*(hit1-armor2)

if self.f2.blood<=0:

self.f2.blood=0

if shooter==self.f2:

if m.position in self.f1.frame:

self.f1.blood-=2*(hit2-armor1)

if self.f1.blood<=0:

self.f1.blood=0

def spawn_returnlable(self):

self.returnlable=LabelNode()

self.returnlable.text=('card')

self.returnlable.position=(400,970)

self.returnlable.font=('Arial',30)

self.returnlable.color='purple'

self.add_child(self.returnlable)

def check_loop(self):

global f1money,f2money

if self.f1.shoottotalnum>=100:

if self.f1.shoottotalnum-self.f2.shoottotalnum>=0:

money1=(self.f1.shoottotalnum-self.f2.shoottotalnum)+(self.f1.blood-self.f2.blood)

if money1>0:

f1money+=money1

if money1<=0:

f2money-=money1

self.f1.shoottotalnum=0

self.f2.shoottotalnum=0

self.f1.blood=random.randint(100,120)+lifeplus1

self.f2.blood=random.randint(100,120)+lifeplus2

if self.f2.shoottotalnum>=100:

if self.f2.shoottotalnum-self.f1.shoottotalnum>=0:

money2=(self.f2.shoottotalnum-self.f1.shoottotalnum)+(self.f2.blood-self.f1.blood)

if money2>0:

f2money+=money2

if money2<=0:

f1money-=money2

self.f1.shoottotalnum=0

self.f2.shoottotalnum=0

self.f1.blood=random.randint(100,120)+lifeplus1

self.f2.blood=random.randint(100,120)+lifeplus2

def spawn_winlable(self):

self.winlable=LabelNode()

self.winlable.text=('')

self.winlable.position=(400,400)

self.winlable.font=('Arial',20)

self.winlable.color='black'

self.add_child(self.winlable)

def spawn_winnumlable(self):

global winnum,losenum

self.winnumlable=LabelNode()

self.winnumlable.text=('')

self.winnumlable.position=(150,700)

self.winnumlable.font=('Arial',20)

self.winnumlable.color='black'

self.add_child(self.winnumlable)

def check_win(self):

global f1money,f2money,winnum,losenum

if self.f1.blood==0:

self.f1.blood=random.randint(100,120)+lifeplus1

self.f2.blood=random.randint(100,120)+lifeplus2

losenum+=1

self.winlable.text='you lose,your got 250 money,enemy got 125 money'

f1money+=250

f2money+=125

if self.f2.blood==0:

self.f1.blood=random.randint(100,120)+lifeplus1

self.f2.blood=random.randint(100,120)+lifeplus2

winnum+=1

self.winlable.text='you win,enemy got 250 money,you got 125 money'

f2money+=250

f1money+=125

def did_change_size(self):

pass

def update(self):

import random

global f1money,f2money,winnum,losenum,silence1,silence2

if silence1:

self.f1.drawcircle()

else:

self.f1.endcircle()

if silence2:

self.f2.drawcircle()

else:

self.f2.endcircle()

for m in self.f1.mlist:

if m.position.x<=0 or m.position.x>=self.wtotalnum*self.diameter or m.position.y<=0 or m.position.y>=self.htotalnum*self.diameter:

m.remove_from_parent()

for m in self.f2.mlist:

if m.position.x<=0 or m.position.x>=self.wtotalnum*self.diameter or m.position.y<=0 or m.position.y>=self.htotalnum*self.diameter:

m.remove_from_parent()

self.shootnumlable1.text='yourcatch:'+str(self.f1.shoottotalnum)

self.shootnumlable2.text='enemycatch:'+str(self.f2.shoottotalnum)

self.bloodlable1.text='yourblood:'+str(self.f1.blood)

self.bloodlable2.text='enemyblood:'+str(self.f2.blood)

#self.shoot(self.f1,'emj:Baseball')

#self.shoot(self.f2,'emj:Basketball')

self.check_m_collisions(random.choice(self.flist))

self.check_loop()

self.check_win()

self.moneylable1.text='yourmoney:'+str(f1money)

self.moneylable2.text='enemymoney:'+str(f2money)

self.winnumlable.text=('wintimes:'+str(winnum)+' '+'losetimes:'+str(losenum))

file2=open('money1.txt','w')

file2.write(str(f1money))

file2.write(',')

file3=open('money2.txt','w')

file3.write(str(f2money))

file3.write(',')

file14=open('winlosenum.txt','w')

file14.write(str(winnum))

file14.write('\n')

file14.write(str(losenum))

file14.write('\n')

if not silence1:

self.check_get_powerup(self.f1)

if not silence2:

self.check_get_powerup(self.f2)

if self.t>=0.45:

self.f1.rotate(1)

self.f1.move()

self.f2.rotate(1)

self.f2.move()

for f in self.fishlist:

f.rotate(2)

f.move()

#self.spawn_maze_shoot(self.f2)

if not silence2:

self.shoot(self.f2,'emj:Cat_Face',450)

else:

self.shoot(self.f2,'emj:Cat_Face',100)

if not silence1:

self.shoot(self.f1,'emj:Cat_Face_Crying',450)

else:

self.shoot(self.f1,'emj:Cat_Face_Crying',100)

self.t=0

for touch in self.touches.values():

if touch.location in self.returnlable.bbox:

scene_view2.bring_to_front()

def touch_began(self, touch):

pass

def touch_moved(self, touch):

pass

def touch_ended(self, touch):

pass

class MyScene2 (Scene):

def setup(self):

self.wtotalnum=8

self.htotalnum=8

self.dm=100

self.diameter=self.dm

self.radius=self.diameter/2

self.bgpic=Texture('texture2.png')

self.bgpic.anchor_point=(0,0)

self.bgpic.position=(0,0)

#self.bgpic.size=(self.wtotalnum*self.dm,self.htotalnum*self.dm)

#self.add_child(self.bgpic)

#self.mlist=[]

self.fishlist=[]

self.ground=SpriteNode('plf:BG_Blue_land')

self.ground.anchor_point=(0,0)

self.ground.position=(0,0)

self.ground.size=(self.wtotalnum*self.dm,self.htotalnum*self.dm)

#self.ground.size=self.bgpic.size

self.add_child(self.ground)

self.m1=maze(parent=self)

self.m1.settexture('emj:Baby_Chick_2')

self.m1.setwhnum(1,8)

self.m1.setpos()

self.m2=maze(parent=self)

self.m2.settexture('emj:Bear_Face')

self.m2.setwhnum(4,4)

self.m2.setpos()

self.mlist=[]

self.mlist.append(self.m1)

self.mlist.append(self.m1)

#self.spawn_maze()

self.move(self.m1)

self.spawn_returnlable()

self.mlistforscene2=[]

self.poson=[[0 for j in range(self.wtotalnum)]for j in range(self.wtotalnum)]

for i in range(self.htotalnum):

for j in range(self.wtotalnum):

pass

#self.poson[i][j]=0

#print(self.poson[i][j])

def spawn_returnlable(self):

self.returnlable=LabelNode()

self.returnlable.text=('back')

self.returnlable.position=(400,970)

self.returnlable.font=('Arial',30)

self.returnlable.color='purple'

self.add_child(self.returnlable)

def move(self,maze):

self.wstep=self.wtotalnum

self.hstep=self.htotalnum

dxt=self.wtotalnum*self.diameter

dyt=self.htotalnum*self.diameter

x=1*self.diameter-self.radius

y=8*self.diameter-self.radius

A00=A.move_to(x,y,0,TIMING_EASE_OUT)

if maze.direction==0:

dx=(self.wstep-1)*self.diameter

dy=0

A0=A.move_by(dx, dy,dx/dxt,TIMING_EASE_OUT)

maze.direction+=1

if maze.direction==1:

dx=0

dy=(self.hstep-1)*self.diameter

A1=A.move_by(dx,-dy,dy/dyt,TIMING_EASE_OUT)

maze.direction+=1

if maze.direction==2:

dx=(self.wstep-1)*self.diameter

dy=0

A2=A.move_by(-dx, dy,dx/dxt,TIMING_EASE_OUT)

maze.direction+=1

if maze.direction==3:

self.hstep-=1

dx=0

dy=(self.hstep-1)*self.diameter

A3=A.move_by(dx,dy,dy/dyt,TIMING_EASE_OUT)

maze.direction+=1

self.wstep-=1

self.hstep-=1

#round2

if maze.direction==4:

dx=(self.wstep-1)*self.diameter

dy=0

B0=A.move_by(dx, dy,dx/dxt,TIMING_EASE_OUT)

maze.direction+=1

if maze.direction==5:

dx=0

dy=(self.hstep-1)*self.diameter

B1=A.move_by(dx,-dy,dy/dyt,TIMING_EASE_OUT)

maze.direction+=1

if maze.direction==6:

self.wstep-=1

dx=(self.wstep-1)*self.diameter

dy=0

B2=A.move_by(-dx, dy,dx/dxt,TIMING_EASE_OUT)

maze.direction+=1

if maze.direction==7:

self.hstep-=1

dx=0

dy=(self.hstep-1)*self.diameter

B3=A.move_by(dx,dy,dy/dyt,TIMING_EASE_OUT)

maze.direction+=1

self.wstep-=1

self.hstep-=1

#round3 same as round2

if maze.direction==8:

dx=(self.wstep-1)*self.diameter

dy=0

C0=A.move_by(dx, dy,dx/dxt,TIMING_EASE_OUT)

maze.direction+=1

if maze.direction==9:

dx=0

dy=(self.hstep-1)*self.diameter

C1=A.move_by(dx,-dy,dy/dyt,TIMING_EASE_OUT)

maze.direction+=1

if maze.direction==10:

self.wstep-=1

dx=(self.wstep-1)*self.diameter

dy=0

C2=A.move_by(-dx, dy,dx/dxt,TIMING_EASE_OUT)

maze.direction+=1

if maze.direction==11:

self.hstep-=1

dx=0

dy=(self.hstep-1)*self.diameter

C3=A.move_by(dx,dy,dy/dyt,TIMING_EASE_OUT)

maze.direction+=1

self.wstep-=1

self.hstep-=1

#round 4 same as round2

if maze.direction==12:

dx=(self.wstep-1)*self.diameter

dy=0

D0=A.move_by(dx, dy,dx/dxt,TIMING_EASE_OUT)

maze.direction+=1

if maze.direction==13:

dx=0

dy=(self.hstep-1)*self.diameter

D1=A.move_by(dx,-dy,dy/dyt,TIMING_EASE_OUT)

maze.direction+=1

if maze.direction==14:

self.wstep-=1

dx=(self.wstep-1)*self.diameter

dy=0

D2=A.move_by(-dx, dy,dx/dxt,TIMING_EASE_OUT)

maze.direction+=1

if maze.direction==15:

self.hstep-=1

dx=0

dy=(self.hstep-1)*self.diameter

D3=A.move_by(dx,dy,dy/dyt,TIMING_EASE_OUT)

maze.direction+=1

self.wstep-=1

self.hstep-=1

maze.run_action(A.repeat(A.sequence(A0,A1,A2,A3,B0,B1,B2,B3,C0,C1,C2,C3,D0,D1,D2,D3,A00),0))

def movetoout(self,maze):

self.wstep=self.wtotalnum

self.hstep=self.htotalnum

dxt=self.wtotalnum*self.diameter

dyt=self.htotalnum*self.diameter

x=4*self.diameter-self.radius

y=4*self.diameter-self.radius

A00=A.move_to(x,y,0,TIMING_EASE_OUT)

if maze.direction==0:

dx=(self.wstep-1)*self.diameter

dy=0

A0=A.move_by(-dx, -dy,dx/dxt,TIMING_EASE_OUT)

maze.direction+=1

if maze.direction==1:

dx=0

dy=(self.hstep-1)*self.diameter

A1=A.move_by(-dx,dy,dy/dyt,TIMING_EASE_OUT)

maze.direction+=1

if maze.direction==2:

dx=(self.wstep-1)*self.diameter

dy=0

A2=A.move_by(dx, -dy,dx/dxt,TIMING_EASE_OUT)

maze.direction+=1

if maze.direction==3:

self.hstep-=1

dx=0

dy=(self.hstep-1)*self.diameter

A3=A.move_by(-dx,-dy,dy/dyt,TIMING_EASE_OUT)

maze.direction+=1

self.wstep-=1

self.hstep-=1

#round2

if maze.direction==4:

dx=(self.wstep-1)*self.diameter

dy=0

B0=A.move_by(-dx, -dy,dx/dxt,TIMING_EASE_OUT)

maze.direction+=1

if maze.direction==5:

dx=0

dy=(self.hstep-1)*self.diameter

B1=A.move_by(-dx,dy,dy/dyt,TIMING_EASE_OUT)

maze.direction+=1

if maze.direction==6:

self.wstep-=1

dx=(self.wstep-1)*self.diameter

dy=0

B2=A.move_by(dx, -dy,dx/dxt,TIMING_EASE_OUT)

maze.direction+=1

if maze.direction==7:

self.hstep-=1

dx=0

dy=(self.hstep-1)*self.diameter

B3=A.move_by(-dx,-dy,dy/dyt,TIMING_EASE_OUT)

maze.direction+=1

self.wstep-=1

self.hstep-=1

#round3 same as round2

if maze.direction==8:

dx=(self.wstep-1)*self.diameter

dy=0

C0=A.move_by(-dx, -dy,dx/dxt,TIMING_EASE_OUT)

maze.direction+=1

if maze.direction==9:

dx=0

dy=(self.hstep-1)*self.diameter

C1=A.move_by(-dx,dy,dy/dyt,TIMING_EASE_OUT)

maze.direction+=1

if maze.direction==10:

self.wstep-=1

dx=(self.wstep-1)*self.diameter

dy=0

C2=A.move_by(dx, -dy,dx/dxt,TIMING_EASE_OUT)

maze.direction+=1

if maze.direction==11:

self.hstep-=1

dx=0

dy=(self.hstep-1)*self.diameter

C3=A.move_by(-dx,-dy,dy/dyt,TIMING_EASE_OUT)

maze.direction+=1

self.wstep-=1

self.hstep-=1

#round 4 same as round2

if maze.direction==12:

dx=(self.wstep-1)*self.diameter

dy=0

D0=A.move_by(-dx, -dy,dx/dxt,TIMING_EASE_OUT)

maze.direction+=1

if maze.direction==13:

dx=0

dy=(self.hstep-1)*self.diameter

D1=A.move_by(-dx,dy,dy/dyt,TIMING_EASE_OUT)

maze.direction+=1

if maze.direction==14:

self.wstep-=1

dx=(self.wstep-1)*self.diameter

dy=0

D2=A.move_by(dx, -dy,dx/dxt,TIMING_EASE_OUT)

maze.direction+=1

if maze.direction==15:

self.hstep-=1

dx=0

dy=(self.hstep-1)*self.diameter

D3=A.move_by(-dx,-dy,dy/dyt,TIMING_EASE_OUT)

maze.direction+=1

self.wstep-=1

self.hstep-=1

maze.run_action(A.repeat(A.sequence(D2,D1,D0,C3,C2,C1,C0,B3,B2,B1,B0,A3,A2,A1,A0,A00),0))

def spawn_maze(self):

for i in range(1):

wn=random.randint(1,8)

hn=random.randint(1,8)

if self.poson[hn-1][wn-1]==0:

name=random.choice(namelist)

m=maze(parent=self)

m.name=name

m.settexture(name)

self.poson[hn-1][wn-1]=1

m.setwhnum(wn,hn)

m.setpos()

self.mlistforscene2.append(m)

def check_silence_for2(self):

global silence1,silence2,timelapfor1,timelapfor2

for m in self.mlistforscene2:

if m.position in self.m1.frame:

if m.name=='emj:Anger_Symbol':

silence2=True

self.t=0

if silence2==True:

if self.t>=timelapfor2:

silence2=False

def check_silence_for1(self):

global silence1,silence2,timelapfor1,timelapfor2

for m in self.mlistforscene2:

if m.position in self.m2.frame:

if m.name=='emj:Anger_Symbol':

silence1=True

self.t=0

if silence1==True:

if self.t>=timelapfor1:

silence1=False

def check_for_mazecollision(self,maze):

global silence1,silence2,timelapfor1,timelapfor2

for m in self.mlistforscene2:

if m.position in maze.frame:

if maze==self.m1:

if m.name not in popnamelist1:

levelupyes1[m.name]=False

popnamelist1.append(m.name)

if maze==self.m2:

if m.name not in popnamelist2:

levelupyes2[m.name]=False

popnamelist2.append(m.name)

wn=(m.position.x+self.radius)/self.diameter

hn=(m.position.y+self.radius)/self.diameter

self.poson[int(hn)-1][int(wn)-1]=0

m.remove_from_parent()

self.mlistforscene2.remove(m)

def levelupdate(self):

global popnamelist1,popnamelist2,level1,level2,usedcount1,usedcount2,levelupyes1,levelupyes2

popnamelist1copy=list(set(popnamelist1))

for popname in popnamelist1copy:

if levelupyes1 is not None:

if not levelupyes1[popname]:

level1[popname]=1

usedcount1[popname]=0

popnamelist2copy=list(set(popnamelist2))

for popname in popnamelist2copy:

if levelupyes2 is not None:

if not levelupyes2[popname]:

level2[popname]=1

usedcount2[popname]=0

def levelupforf2(self):

global lnum2,lifeplus1,lifeplus2,armor2,hit2,f2money,popnamelist2copy,usedcount2,popnamelist2,level2,timelapfor1,levelupyes2

popnamelist2copy=list(set(popnamelist2))

if popnamelist2copy:

self.name=random.choice(popnamelist2copy)

if level2.get(self.name) is not None:

lnum2=level2.get(self.name)

if popnamelist2.count(self.name) is not None and usedcount2.get(self.name) is not None:

if popnamelist2.count(self.name)-usedcount2[self.name]>=lnum2*(lnum2+1):

? if f2money>=lnum2*(lnum2+1)*1000:

? usedcount2[self.name]+=lnum2*(lnum2+1)

? f2money-=lnum2*(lnum2+1)*1000

? lnum2+=1

? level2[self.name]=lnum2

? if levelupyes2 is not None:

? ? levelupyes2[self.name]=True

? if self.name=='emj:Ambulance':

? ? lifeplus2+=10

? if self.name=='emj:Imp':

? ? armor2+=0.5

? if self.name=='emj:Direct_Hit':

? ? hit2+=1.5

? if self.name=='emj:Anger_Symbol':

? ? timelapfor1+=0.2

def did_change_size(self):

pass

def update(self):

global popnamelist1,popnamelist2,levelupyes1,levelupyes2,level1,level2,usedcount1,usedcount2,timelapfor1,timelapfor2

save_obj(levelupyes1,'levelupyes1' )

save_obj(levelupyes2,'levelupyes2' )

save_obj(level1,'level1' )

save_obj(level2,'level2' )

save_obj(usedcount1,'usedcount1' )

save_obj(usedcount2,'usedcount2' )

file12=open('hitarmorlifeplus1.txt','w')

file12.write(str(hit1))

file12.write('\n')

file12.write(str(armor1))

file12.write('\n')

file12.write(str(lifeplus1))

file12.write('\n')

file12.write(str(timelapfor1))

file12.write('\n')

file13=open('hitarmorlifeplus2.txt','w')

file13.write(str(hit2))

file13.write('\n')

file13.write(str(armor2))

file13.write('\n')

file13.write(str(lifeplus2))

file13.write('\n')

file13.write(str(timelapfor2))

file13.write('\n')

self.check_silence_for1()

self.check_silence_for2()

self.check_for_mazecollision(self.m1)

self.check_for_mazecollision(self.m2)

self.levelupforf2()

self.levelupdate()

file4=open('popnamelist1.txt','w')

for str4 in popnamelist1:

file4.write(str4)

file4.write('\n')

file5=open('popnamelist2.txt','w')

for str5 in popnamelist2:

file5.write(str5)

file5.write('\n')

self.move(self.m1)

self.movetoout(self.m2)

if self.t>=2.5:

self.spawn_maze()

self.t=0

for touch in self.touches.values():

if touch.location in self.returnlable.bbox:

scene_view1.bring_to_front()

def touch_began(self, touch):

pass

def touch_moved(self, touch):

pass

def touch_ended(self, touch):

pass

class popview1(ui.View):

? ? def __init__(self):

? ? popnamelist1copy=list(set(popnamelist1))

? ? popnamelist1copy.sort(key=popnamelist1.index)

? ? if len(popnamelist1copy)==0:

? ? ? self.indexi=0

? ? if popnamelist1copy:

? ? ? self.indexi=0

? ? def did_load(self):

? ? global popnamelist1,usedcount1,level1,levelupyes1

? ? self.iv11 = self['imageview11']

? ? popnamelist1copy=list(set(popnamelist1))

? ? popnamelist1copy.sort(key=popnamelist1.index)

? ? if popnamelist1copy:

? ? ? self.indexi=0

? ? ? self.name=popnamelist1copy[self.indexi]

? ? self.iv11.image = ui.Image.named(self.name)

? ? self.button11=self['button11']

? ? self.button11.action=self.last

? ? self.button21=self['button21']

? ? self.button21.action=self.next

? ? self.lable11=self['label11']

? ? self.button31=self['button31']

? ? self.button31.action=self.levelup

? ? if levelupyes1=={}:

? ? ? lnum=0

? ? ? usedcount1[self.name]=0

? ? elif not levelupyes1[self.name]:

? ? ? lnum=0

? ? ? usedcount1[self.name]=0

? ? if level1.get(self.name) is not None:

? ? ? lnum=level1.get(self.name)

? ? ? if lnum==1:

? ? ? usedcount1[self.name]=0

? ? self.lable11.text='level'+str(lnum)+' '+str(popnamelist1.count(self.name)-usedcount1[self.name])+'/'+str(lnum*(lnum+1))

? ?

? ? self.button31.title='levelup cost'+str(lnum*(lnum+1)*1000)

? ? def levelup(self,sender):

? ? global lifeplus1,lifeplus2,armor1,hit1,f1money,usedcount1,level1,levelupyes1,popnamelist1,timelapfor2

? ? if level1.get(self.name) is not None:

? ? ? lnum=level1.get(self.name)

? ? if popnamelist1.count(self.name)-usedcount1[self.name]>=lnum*(lnum+1):

? ? ? if f1money>=lnum*(lnum+1)*1000:

? ? ? usedcount1[self.name]+=lnum*(lnum+1)

? ? ? f1money-=lnum*(lnum+1)*1000

? ? ? lnum+=1

? ? ? level1[self.name]=lnum

? ? ? levelupyes1[self.name]=True

? ? ? if self.name=='emj:Ambulance':

? ? ? ? lifeplus1+=10

? ? ? if self.name=='emj:Imp':

? ? ? ? armor1+=0.5

? ? ? if self.name=='emj:Direct_Hit':

? ? ? ? hit1+=1.5

? ? ? if self.name=='emj:Anger_Symbol':

? ? ? ? timelapfor2+=0.2

? ?

? ? ? self.lable11.text='level'+str(lnum)+' '+str(popnamelist1.count(self.name)-usedcount1[self.name])+'/'+str(lnum*(lnum+1))

? ?

? ? ? self.button31.title='levelup cost'+str(lnum*(lnum+1)*1000)

? ?

? ?

? ?

? ?

? ? def last(self,sender):

? ? global popnamelist1,usedcount1,level1

? ? popnamelist1copy=list(set(popnamelist1))

? ? popnamelist1copy.sort(key=popnamelist1.index)

? ? if len(popnamelist1copy)>0:

? ? self.indexi-=1

? ? if self.indexi<=0:

? ? ? self.indexi=0

? ? self.name=popnamelist1copy[self.indexi]

? ? self.iv11.image = ui.Image.named(self.name)

? ? if level1.get(self.name) is None:

? ? ? lnum=0

? ? if level1.get(self.name) is not None:

? ? ? lnum=level1.get(self.name)

? ? ? #lnum=level1[self.name]

? ? self.lable11.text='level'+str(lnum)+' '+str(popnamelist1.count(self.name)-usedcount1[self.name])+'/'+str(lnum*(lnum+1))

? ?

? ? ? self.button31.title='levelup cost'+str(lnum*(lnum+1)*1000)

? ?

? ? def next(self,sender):

? ? global popnamelist1,usedcount1,level1

? ? popnamelist1copy=list(set(popnamelist1))

? ? popnamelist1copy.sort(key=popnamelist1.index)

? ? if len(popnamelist1copy)>0:

? ? self.indexi+=1

? ? if self.indexi>=len(popnamelist1copy)-1:

? ? ? self.indexi=len(popnamelist1copy)-1

? ? self.name=popnamelist1copy[self.indexi]

? ? self.iv11.image = ui.Image.named(self.name)

? ? if level1.get(self.name) is None:

? ? ? lnum=0

? ? if level1.get(self.name) is not None:

? ? ? lnum=level1.get(self.name)

? ? self.lable11.text='level'+str(lnum)+' '+str(popnamelist1.count(self.name)-usedcount1[self.name])+'/'+str(lnum*(lnum+1))

? ?

? ? ? self.button31.title='levelup cost'+str(lnum*(lnum+1)*1000)

? ?

? ?

class popview2(ui.View):

? ? def __init__(self):

? ? popnamelist2copy=list(set(popnamelist2))

? ? popnamelist2copy.sort(key=popnamelist2.index)

? ? if len(popnamelist2copy)==0:

? ? ? self.indexi=0

? ? if popnamelist2copy:

? ? ? self.indexi=0

? ? def did_load(self):

? ? global popnamelist2,usedcount2,level2,levelupyes2

? ?

? ? self.iv12 = self['imageview12']

? ? popnamelist2copy=list(set(popnamelist2))

? ? popnamelist2copy.sort(key=popnamelist2.index)

? ? if popnamelist2copy:

? ? ? self.indexi=0

? ? ? self.name=popnamelist2copy[self.indexi]

? ? self.iv12.image = ui.Image.named(self.name)

? ? self.button12=self['button12']

? ? self.button12.action=self.last

? ? self.button22=self['button22']

? ? self.button22.action=self.next

? ? self.lable12=self['label12']

? ? self.button32=self['button32']

? ? self.button32.action=self.levelup

? ? global lnum2

? ? if levelupyes2=={}:

? ? ? lnum2=0

? ? ? usedcount2[self.name]=0

? ? elif levelupyes2 is not None:

? ? ? if levelupyes2.get(self.name) is None:

? ? ? lnum2=0

? ? ? usedcount2[self.name]=0

? ? if level2.get(self.name) is not None:

? ? ? lnum2=level2.get(self.name)

? ? ? if lnum2==1:

? ? ? usedcount2[self.name]=0

? ? self.lable12.text='level'+str(lnum2)+' '+str(popnamelist2.count(self.name)-usedcount2[self.name])+'/'+str(lnum2*(lnum2+1))

? ?

? ? self.button32.title='levelup cost'+str(lnum2*(lnum2+1)*1000)

? ? def levelup(self,sender):

? ? pass

? ? '''

? ? global lifeplus2,armor2,hit2

? ? if level2.get(self.name) is not None:

? ? ? lnum=level2.get(self.name)

? ? if popnamelist2.count(self.name)-usedcount2[self.name]>=lnum*(lnum+1):

? ? ? usedcount2[self.name]+=lnum*(lnum+1)

? ? ? lnum+=1

? ? ? level2[self.name]=lnum

? ? ? levelupyes2[self.name]=True

? ? ? if self.name=='emj:Ambulance':

? ? ? lifeplus2+=10

? ? ? if self.name=='emj:Imp':

? ? ? armor2+=1

? ? ? if self.name=='emj:Direct_Hit':

? ? ? hit2+=1

? ?

? ? ? self.lable12.text='level'+str(lnum)+' '+str(popnamelist2.count(self.name)-usedcount2[self.name])+'/'+str(lnum*(lnum+1))

? ?

? ? ? self.button32.title='levelup cost'+str(lnum*(lnum+1)*1000)'''

? ?

? ? def last(self,sender):

? ? global popnamelist2,usedcount2,level2

? ? popnamelist2copy=list(set(popnamelist2))

? ? popnamelist2copy.sort(key=popnamelist2.index)

? ? if len(popnamelist2copy)>0:

? ? self.indexi-=1

? ? if self.indexi<=0:

? ? ? self.indexi=0

? ? self.name=popnamelist2copy[self.indexi]

? ? self.iv12.image = ui.Image.named(self.name)

? ? global lnum2

? ? lnum2=0

? ? if level2.get(self.name) is not None:

? ? ? lnum2=level2.get(self.name)

? ? self.lable12.text='level'+str(lnum2)+' '+str(popnamelist2.count(self.name)-usedcount2[self.name])+'/'+str(lnum2*(lnum2+1))

? ?

? ? ? self.button32.title='levelup cost'+str(lnum2*(lnum2+1)*1000)

? ? def next(self,sender):

? ? global popnamelist2,usedcount2,level2

? ? popnamelist2copy=list(set(popnamelist2))

? ? popnamelist2copy.sort(key=popnamelist2.index)

? ? if len(popnamelist2copy)>0:

? ? self.indexi+=1

? ? if self.indexi>=len(popnamelist2copy)-1:

? ? ? self.indexi=len(popnamelist2copy)-1

? ? self.name=popnamelist2copy[self.indexi]

? ? self.iv12.image = ui.Image.named(self.name)

? ? global lnum2

? ? lnum2=0

? ? if level2.get(self.name) is not None:

? ? ? lnum2=level2.get(self.name)

? ? self.lable12.text='level'+str(lnum2)+' '+str(popnamelist2.count(self.name)-usedcount2[self.name])+'/'+str(lnum2*(lnum2+1))

? ?

? ? ? self.button32.title='levelup cost'+str(lnum2*(lnum2+1)*1000)

? ?

? ?

? ? ? ?

if __name__ == '__main__':

v = ui.View()

scene_view2 = SceneView(frame=v.frame)

scene_view2.flex= 'WH'

scene_view2.scene = MyScene2()

scene_view1 = SceneView(frame=v.frame)

scene_view1.flex= 'WH'

scene_view1.scene = MyScene1()

b1 = ui.Button()

b1.frame = (10,180,80,80)

b1.image = ui.Image.named('emj:Baby_Chick_2')

b2 = ui.Button()

b2.frame = (10,580,80,80)

b2.image = ui.Image.named('emj:Bear_Face')

def b_action1(sender):

x = sender.x + sender.width/2

y = sender.y + sender.height/2

pv = ui.load_view("pop1")

#pv.name = 'chickencards'

pv.present('popover',popover_location = (x,y))

def b_action2(sender):

x = sender.x + sender.width/2

y = sender.y + sender.height/2

pv = ui.load_view("pop2")

#pv.name = 'bearcards'

pv.present('popover',popover_location = (x,y))

?

b1.action = b_action1

scene_view2.add_subview(b1)

b2.action = b_action2

scene_view2.add_subview(b2)

#v.add_subview(root_view)

v.add_subview(scene_view2)

v.add_subview(scene_view1)

v.present('fullscreen', hide_title_bar=True)

#run(MyScene(), show_fps=False)


https://www.xamrdz.com/backend/34a1994062.html

相关文章: