Exemplo n.º 1
0
 def create_level(self, size):
     """
     Creates level object and adds it to the level dict 
     :param size: int 
     """
     _level = Level(size)
     print("added level", _level.id)
     self.levels[_level.get_id()] = _level
Exemplo n.º 2
0
 def loadLevelsFromDir(self):
     files = [f for f in listdir(self.lvldir) if isfile(self.lvldir + f)]
     self.nlevels = len(files)
     print(self.nlevels)
     for i in range(self.nlevels):
         tmp = Level(i)  # This generates a random file anyway
         tmp.loadTilemapFromFile(
             self.lvldir +
             files[i])  # Now we ignore it and just load from a file
         self.levels.append(tmp)
Exemplo n.º 3
0
for i in range(0,imw,64):
    surfbuff = pg.Surface((64,64))
    surfbuff.blit(texim,(0,0),pg.Rect(i,0,64,64))
    tex_dict[n] = load_image(surfbuff.copy(),True)
    n += 1

n = 0

for i in range(0,spriteim.get_width(),64):
    surfbuff = pg.Surface((64,64))
    surfbuff.blit(spriteim,(0,0),pg.Rect(i,0,64,64))
    sprite_dict[n] = load_image(surfbuff.copy(),False)
    n += 1

collsprites = [0,1]
sprites = [(2,17,2),(16,1,1),(21,1,1),(2,1,1),(12,17,2),(1,1,0)]

for i in sprites:
    if i[2] in collsprites:
        levelmap[i[1]][i[0]] = -1

level = Level(levelmap,tex_dict,sprite_dict,sprites,64)
level.pack_tex()

f = open("res/level/block.level",'wb')

pickle.dump(level,f)

f.close()
Exemplo n.º 4
0
 def generateLevels(self):
     for i in range(self.nlevels):
         self.levels.append(Level(i))