Esempio n. 1
0
 def makeEnt(self, entType, image = None, x = 0, y = 0, frames = 12, direction = 1, cycle = 3, spd = 200, interaction = None, frameSpeed = 100):
     entType = entType.upper()
     if entType == "WALL":
         entity = WALL.Wall(x, y, image)
         self.newLevel.all_sprites.add(entity)
         self.newLevel.WALL_LAYER.add(entity)
     elif entType == "PLAYER":
         entity = PC(x, y, image, spd, direction, frames, cycle, level = self, frameSpeed = frameSpeed)
         self.newLevel.packPC(entity, x, y)
     elif entType == "NPC":
         entity = NPC.Npc(image, x, y, frames, direction, cycle, spd, level = self)
         self.newLevel.all_sprites.add(entity)
         self.newLevel.NPC_LAYER.add(entity)
     elif entType == "TRIGGER":
         entity = TRIGGER.Trigger(x, y, 64,64, interact = interaction, transparent = True, level = self)
         self.newLevel.all_sprites.add(entity)
         self.newLevel.TRIGGER_LAYER.add(entity)
     elif entType == "ANIMATION":
         entity = NPC.Npc(image = image, x = x, y = y, frames = frames, level = self)
         self.newLevel.all_sprites.add(entity)
         self.newLevel.NPC_LAYER.add(entity)
         self.newLevel.animated_sprites.add(entity)
         self.newLevel.solid_sprites.add(entity)
     elif entType == "MELE":
         entity = mele.Mele(image = image, x = x, y = y, frames = frames, frameSpeed = 10)
         self.newLevel.all_sprites.add(entity)
         self.newLevel.NPC_LAYER.add(entity)
Esempio n. 2
0
 def loadNpcs(self, filename):
     data = self.loadData(filename)
     for row, tiles in enumerate(data):
                 for col, tile in enumerate(tiles):
                     if int(tile) > -1:
                         ent = NPC.Npc(x = col * self.tileHeight, y = row * self.tileWidth, image = self.tiles[int(tile)], level = self)
                         self.newLevel.NPC_LAYER.add(ent)
                         self.newLevel.all_sprites.add(ent)
                         self.newLevel.solid_sprites.add(ent)
                         self.newLevel.npc_sprites.add(ent)
Esempio n. 3
0
def spawn_npcs():
    for npc in SETTINGS.levels_list[SETTINGS.current_level].npcs:
        if [x for x in SETTINGS.npc_types
                if x['id'] == npc[2]][0]['name'] == 'random':
            random.seed(SETTINGS.seed)
            stats = copy.deepcopy(
                random.choice(
                    [x for x in SETTINGS.npc_types if x['name'] != 'random']))
        else:
            stats = copy.deepcopy(
                [x for x in SETTINGS.npc_types if x['id'] == npc[2]][0])

        try:
            sounds = ([
                x for x in SETTINGS.npc_soundpacks
                if x['name'] == stats['soundpack']
            ][0])
        except:
            print("Error loading NPC! No soundpack with name ",
                  stats['soundpack'])
        stats['pos'] = npc[0]
        stats['face'] = npc[1]
        SETTINGS.npc_list.append(
            NPC.Npc(stats, sounds, path.join(*stats['filepath'])))