当前位置: 首页>>代码示例>>Python>>正文


Python Img.np方法代码示例

本文整理汇总了Python中Img.np方法的典型用法代码示例。如果您正苦于以下问题:Python Img.np方法的具体用法?Python Img.np怎么用?Python Img.np使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Img的用法示例。


在下文中一共展示了Img.np方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: import Img [as 别名]
# 或者: from Img import np [as 别名]
 def __init__(self, edit, level=None):
     self.edit = edit
     self.playerdead = False
     self.done = False
     self.level = level
     self.exitcode="NORMAL"
     if edit:
         self.t = []
         self.o = []
         for _ in range(20):
             self.t.append([0] * 20)
             self.o.append([0] * 20)
         self.e = []
     else:
         self.e = []
         self.ps=[]
         if level=="sav":
             savfile = open(Img.np("lvls//save.sav"), "r")
         elif len(level)==2:
             savfile = open(Img.np("lvls//%s-%s.sav" % tuple(level)), "r")
         else:
             savfile = open(Img.np("lvls//%s-%s-%s.sav" % tuple(level)), "r")
         self.t = []
         self.o = []
         self.fx = []
         self.bfx = []
         if level[0]==3 and level[1]!=8:
             for _ in range(randint(50,60)):
                 self.bfx.append(FX.Star(randint(0,638),randint(0,638)))
         savr = savfile.readlines()
         self.fltext = savr[0][:-1]
         del savr[0]
         for row in savr[:20]:
             self.t.append([int(s) for s in row.split()])
         for x, row in enumerate(savr[20:]):
             self.o.append([None] * 20)
             crow = [int(s) for s in row.split()]
             for y, n in enumerate(crow):
                 if n:
                     eo = self.eoconvert(n)
                     if eo[1] == "obj":
                         self.o[x][y] = eo[0](x, y)
                     elif eo[1] == "ent":
                         self.e.append(eo[0](x, y))
                     elif eo[1] == "spawn":
                         self.ps.append(eo[0](x, y))
                         self.e.append(self.ps[-1])
                         self.akey=self.ps[-1].akey
                     elif eo[1] == "gravblock":
                         self.e.append(Entities.SokoBlokGrav(x,y,eo[0]))
         if level[1]==8:
             try:
                 self.boss=Bosses.bosses[level[0]-1](9,9)
                 if level[0]==6:
                     self.o[9][9]=self.boss
                 else:
                     self.e.append(self.boss)
             except IndexError:
                 pass
         savfile.close()
开发者ID:NoNotCar,项目名称:BombAdventures,代码行数:62,代码来源:World.py

示例2: __init__

# 需要导入模块: import Img [as 别名]
# 或者: from Img import np [as 别名]
 def __init__(self,level,hs):
     self.electric=not level[0]%2
     if self.electric:
         self.ttgo=5460
     self.objects=[[None]*self.size[1] for _ in range(self.size[0])]
     lfile=open(Img.np("levels//%s-%s.sav" % tuple(level)))
     llines=lfile.readlines()
     del llines[0]
     for x,row in enumerate(llines):
         for y,n in enumerate(row.split()):
             if n!="0":
                 obj=n.split(":")
                 for c in editorclasses:
                     if c.symb==obj[0]:
                         newobj=c(int(obj[1]))
                         newobj.fixed=True
                         self.objects[x][y]=newobj
                         if obj[0]=="S":
                             self.fx=x
                             self.fy=y
                             self.nd=D.get_dir(int(obj[1]))
     self.hs=hs
     self.new_pipe()
     self.level=level
     self.nhs=False
开发者ID:NoNotCar,项目名称:OpenPipes,代码行数:27,代码来源:World.py

示例3: __init__

# 需要导入模块: import Img [as 别名]
# 或者: from Img import np [as 别名]
 def __init__(self, level, players,controllers):
     self.done = False
     self.level = level
     self.exitcode="NORMAL"
     self.e = []
     self.ps=[]
     savfile = open(Img.np("lvls//battle//"+level), "r")
     self.t = []
     self.o = []
     self.fx = []
     self.bfx = []
     pn=0
     savr = savfile.readlines()
     for row in savr[:20]:
         self.t.append([int(s) for s in row.split()])
     for x, row in enumerate(savr[20:]):
         self.o.append([None] * 20)
         crow = [int(s) for s in row.split()]
         for y, n in enumerate(crow):
             if n:
                 eo = self.eoconvert(n)
                 if eo[1] == "obj":
                     self.o[x][y] = eo[0](x, y)
                 elif eo[1] == "ent":
                     self.e.append(eo[0](x, y))
                 elif eo[1] == "spawn":
                     self.ps.append(self.pconv[players[pn]](x, y, controllers[pn]))
                     self.e.append(self.ps[-1])
                     pn+=1
     savfile.close()
开发者ID:NoNotCar,项目名称:BombAdventures,代码行数:32,代码来源:BattleWorld.py

示例4: __init__

# 需要导入模块: import Img [as 别名]
# 或者: from Img import np [as 别名]
 def __init__(self,edit,level,lvlsize):
     self.guitorun=None
     self.edit=edit
     self.olist=[]
     if edit:
         self.size=lvlsize
         s=self.size
         self.eworld=[[0]*s[1] for n in range(s[0])]
         self.terr=[[0]*s[1] for n in range(s[0])]
         self.objs=[[None]*(s[1]+1) for n in range(s[0])]
         self.oconvert()
         self.objs[0][0]=[Scroller(0,0)]
         self.player=self.objs[0][0][0]
     else:
         savfile=open(Img.np("lvls/%s-%s.sav" % tuple(level)))
         savr = savfile.readlines()
         self.size=(len(savr)-1,len(savr[1].split()))
         s=self.size
         self.fltext = savr[0][:-1]
         self.terr=[[0]*s[1] for n in range(s[0])]
         self.objs=[[None]*(s[1]+1) for n in range(s[0])]
         self.oconvert()
         del savr[0]
         for x,row in enumerate(savr):
             for y,n in enumerate(row.split()):
                 try:
                     n=int(n)
                 except ValueError:
                     n=self.symbreconvert(n)
                 if n:
                     obj=EDITORLIST[n-1]
                     if obj in Terrain.terrlist:
                         self.set_terr(x,y,n)
                     elif obj in editorobjs:
                         self.spawn(obj(x,y))
                     else:
                         if obj==Player.Player:
                             self.player=obj(x,y)
                             self.spawn(self.player)
                         else:
                             self.spawn(obj(x,y))
     self.complete=False
     self.pdone=False
开发者ID:NoNotCar,项目名称:jump,代码行数:45,代码来源:World.py

示例5: elif

# 需要导入模块: import Img [as 别名]
# 或者: from Img import np [as 别名]
            cdir=c.get_dir_pressed(gevents)
            if (1,0) == cdir:
                acps[n]=(acps[n]+1)%len(pimgs)
            elif (-1,0) == cdir:
                acps[n]=(acps[n]-1)%len(pimgs)
            screen.blit(pimgs[acps[n]],(304,n*32+94))
            if acps[n] in rsps:
                screen.blit(crossimg,(336,n*32+94))
        else:
            screen.blit(pimgs[acps[n]],(304,n*32+94))
            screen.blit(tickimg,(336,n*32+94))
    Img.bcentrex(sfont,"Press <bomb> to join",screen,n*32+128,(255,255,255))
    pygame.display.flip()
    clock.tick(60)
while True:
    lvls=os.listdir(Img.np("lvls/battle/"))
    lvls=[lvl for lvl in lvls if lvl[0]==str(len(rsps))]
    w=BattleWorld.World(choice(lvls), rsps,rsc)
    Img.musplay("boss.ogg")
    while len(w.ps)>=2:
        events = pygame.event.get()
        for event in events:
            if event.type == pygame.QUIT:
                sys.exit()
        screen.fill((125, 255, 255))
        w.update(events)
        w.render(screen)
        pygame.draw.rect(screen,(200,200,200),pygame.Rect(0,640,640,64))
        for pn,p in enumerate(w.ps):
            screen.blit(p.iconv[(0,1)],(0,640+pn*32))
            for n in range(p.rng):
开发者ID:NoNotCar,项目名称:BombAdventures,代码行数:33,代码来源:battle.py

示例6: save

# 需要导入模块: import Img [as 别名]
# 或者: from Img import np [as 别名]
 def save(self):
     savfile = open(Img.np("lvls//save.sav"), "w")
     savfile.write("\n")
     for row in self.eworld:
         savfile.write(" ".join([self.symbconvert(o) for o in row]) + "\n")
     savfile.close
开发者ID:NoNotCar,项目名称:jump,代码行数:8,代码来源:World.py

示例7: len

# 需要导入模块: import Img [as 别名]
# 或者: from Img import np [as 别名]
while True:
    if tutorial:
        w = World.World(1, 0, 2, pnum, 0, kp, 0, (32, 32))
    else:
        w = World.World(1, wgen, puzzles, pnum, pset, kp, godmode, (32 * 2 ** wsizemod, 32 * 2 ** wsizemod))
    while not w.complete:
        e = pygame.event.get()
        for ev in e:
            if ev.type == pygame.QUIT:
                sys.exit()
            elif ev.type == pygame.KEYDOWN and ev.key == pygame.K_p:
                w.run_GUI(GUI.PauseGUI())
            elif ev.type == pygame.KEYDOWN and ev.key == pygame.K_s and pygame.key.get_mods() & pygame.KMOD_LALT:
                screenshotting = True
        screen.fill((100, 100, 100))
        w.update(e)
        w.scrollrender(screen)
        pygame.display.flip()
        if screenshotting:
            pygame.image.save(screen, Img.np(Img.loc + "Screenshots/screen.png"))
            screenshotting = False
        c.tick(60)
    pygame.mixer.music.stop()
    pygame.time.wait(1000)
    if tutorial and pnum < len(Tutorial.tutorials) - 1:
        pnum += 1
    elif not tutorial and pnum < len(Generators.puzzles[pset]) - 1:
        pnum += 1
    else:
        sys.exit()
开发者ID:NoNotCar,项目名称:monolith,代码行数:32,代码来源:monolith.py


注:本文中的Img.np方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。