def score_kill(self, entity): if is_boss(entity): self.player.stats.score += scores.BOSS elif is_player(entity): self.player.stats.score += scores.PLAYER else: self.player.stats.score += scores.GHOST
def handleUpdate(self, update): if update.idnum == 0 or (self.map is None and self.player.stats.hp <= 0): return entity = None if is_living(update.enttype): entity = self.map.layers[2].getById(update.idnum) if entity is None: entity = Entity(update.stats, update.enttype, True, update.name, update.idnum) self.map.layers[2].add(entity) # the monster's not dead, so it's attacking. arrrgh if update.stats.hp > 0 and self.player: self.monster_attack(entity) elif is_player(update.enttype): entity = self.map.layers[2].getById(update.idnum) if entity is None: entity = Entity(update.stats, update.enttype, True, update.name, update.idnum) if self.player is None: self.player = entity x = pygame.display.get_surface().get_width() y = pygame.display.get_surface().get_height() self.hud = hud.HUD(self.player, x, y) self.viewport = viewport.Viewport(self.player, int(x/32), int(y/32)) self.map.layers[2].add(entity) elif is_item(update.enttype): entity = self.map.layers[1].getById(update.idnum) if entity is None: entity = Entity(update.stats, update.enttype, False, update.name, update.idnum) self.map.layers[1].add(entity) elif is_terrain(update.enttype): entity = self.map.layers[0].getById(update.idnum) if entity is None: entity = Entity(update.stats, update.enttype, is_solid_terrain(update.enttype), update.name, update.idnum) self.map.layers[0].add(entity) entity.stats = update.stats