waves
1class Wave: 2 """The class used for generating waves""" 3 def __init__(self, enemy_data: list, spawn_timer: int): 4 self._enemy_data = enemy_data 5 """Enemy data of current wave""" 6 self._spawn_timer = spawn_timer 7 """Time between the spawning of enemies""" 8 self._enemy_list = [] 9 """Enemies that have been spawned""" 10 self._enemy_number = 0 11 """Tracks which enemy is going to be spawned next""" 12 13 def spawn_enemy(self): 14 """Function that spawns enemies""" 15 if self._enemy_number < len(self._enemy_data): 16 """Checks if there are still more enemies to spawn""" 17 this_enemy = self._enemy_data[self._enemy_number] 18 self._enemy_list.append(this_enemy) 19 """Spawns the next enemy""" 20 self._enemy_number += 1 21 """Prepares the next enemy to be spawned""" 22 return this_enemy 23 return None 24 """If there are no enemies to spawn, return None""" 25 26 def _is_wave_complete(self): 27 """Checks if the wave is complete""" 28 return self._enemy_number >= len(self._enemy_data) and all(not enemy.is_alive() for enemy in self._enemy_list)
class
Wave:
2class Wave: 3 """The class used for generating waves""" 4 def __init__(self, enemy_data: list, spawn_timer: int): 5 self._enemy_data = enemy_data 6 """Enemy data of current wave""" 7 self._spawn_timer = spawn_timer 8 """Time between the spawning of enemies""" 9 self._enemy_list = [] 10 """Enemies that have been spawned""" 11 self._enemy_number = 0 12 """Tracks which enemy is going to be spawned next""" 13 14 def spawn_enemy(self): 15 """Function that spawns enemies""" 16 if self._enemy_number < len(self._enemy_data): 17 """Checks if there are still more enemies to spawn""" 18 this_enemy = self._enemy_data[self._enemy_number] 19 self._enemy_list.append(this_enemy) 20 """Spawns the next enemy""" 21 self._enemy_number += 1 22 """Prepares the next enemy to be spawned""" 23 return this_enemy 24 return None 25 """If there are no enemies to spawn, return None""" 26 27 def _is_wave_complete(self): 28 """Checks if the wave is complete""" 29 return self._enemy_number >= len(self._enemy_data) and all(not enemy.is_alive() for enemy in self._enemy_list)
The class used for generating waves
Wave(enemy_data: list, spawn_timer: int)
4 def __init__(self, enemy_data: list, spawn_timer: int): 5 self._enemy_data = enemy_data 6 """Enemy data of current wave""" 7 self._spawn_timer = spawn_timer 8 """Time between the spawning of enemies""" 9 self._enemy_list = [] 10 """Enemies that have been spawned""" 11 self._enemy_number = 0 12 """Tracks which enemy is going to be spawned next"""
def
spawn_enemy(self):
14 def spawn_enemy(self): 15 """Function that spawns enemies""" 16 if self._enemy_number < len(self._enemy_data): 17 """Checks if there are still more enemies to spawn""" 18 this_enemy = self._enemy_data[self._enemy_number] 19 self._enemy_list.append(this_enemy) 20 """Spawns the next enemy""" 21 self._enemy_number += 1 22 """Prepares the next enemy to be spawned""" 23 return this_enemy 24 return None 25 """If there are no enemies to spawn, return None"""
Function that spawns enemies