def get_exit_level(self):
return self.exit["next level"]
- def is_on_enemy(self, x, y):
+ def enemy_at(self, x, y):
for enemy in self.enemies:
if (x, y) == enemy.game_pos:
return True
return enemy
return None
+ def remove_enemy(self, enemy):
+ self.enemies.remove(enemy)
+
def add_enemy(self, enemy, x, y):
"""Add an enemy to an empty floor space near x, y"""
added = False
while not added:
if self.can_walk(x, y, 'floor'):
- if not self.is_on_friend(x, y):
- if not self.is_on_enemy(x, y):
+ if not self.friend_at(x, y):
+ if not self.enemy_at(x, y):
added = True
enemy.game_pos = (x, y)
self.enemies.append(enemy)
added = True
x += random.randint(-1, 1)
y += random.randint(-1, 1)
-