def process_events(): dead_enemies = enemies.intersection(health.killed) for entity_id in dead_enemies: score.award(entity_id) position = spatial.get_position(entity_id) explosions.create(position) manager.destroy_entity(entity_id)
def process_events(): enemy_ids = set(enemies) left_world = enemy_ids.intersection(collider.world_events) for entity_id in left_world: state = enemies[entity_id] amount = state.attempts if amount: state.state = IDLE else: score.award(entity_id) manager.destroy_entity(entity_id) state.attempts = amount - 1 player_hit = enemy_ids.intersection(collider.collide_events) for entity_id in player_hit: health.apply_damage(player.player_id, DAMAGE) position = spatial.get_position(entity_id) explosions.create(position, big=False) manager.destroy_entity(entity_id)
def process_events(): bullet_ids = set(bullets) left_world = bullet_ids.intersection(collider.world_events) for entity_id in left_world: manager.destroy_entity(entity_id) global hit, hit_data hit = set() hit_data = collections.Counter() struck_target = bullet_ids.intersection(collider.collide_events) for entity_id in struck_target: if entity_id not in bullets: continue target_ids = collider.collide_events_data[entity_id] owner_id = bullets[entity_id][1] target_ids = [id_ for id_ in target_ids if id_ != owner_id] if target_ids: map(hit.add, target_ids) hit_data.update(target_ids) position = spatial.get_position(entity_id) explosions.create(position, big=False) manager.destroy_entity(entity_id)
def apply_missile_damage(target_ids, data): global _hit, _hit_data explosions.create(data, big=True) map(_hit.add, target_ids) _hit_data.update(target_ids)