diff --git a/src/scenes/story/boss_fight.py b/src/scenes/story/boss_fight.py index 5f3bb25..7468dda 100644 --- a/src/scenes/story/boss_fight.py +++ b/src/scenes/story/boss_fight.py @@ -118,15 +118,27 @@ class Wave: def __init__(self) -> None: self.wave_list = [ ["__rainning_projectiles"], - ["__rainning_projectiles", "__rainning_projectiles"], - ["__rainning_projectiles", "__create_zone_attack"], + ["__rainning_projectiles", "__horizontal_projectile"], [ "__rainning_projectiles", "__rainning_projectiles", "__create_zone_attack", ], - ["__rainning_projectiles", "__create_spike"], - ["__rainning_projectiles", "__rainning_projectiles", "__create_spike"], + [ + "__rainning_projectiles", + "__rainning_projectiles", + "__horizontal_projectile", + "__create_zone_attack", + ], + [ + "__rainning_projectiles", + "__create_spike", + ], + [ + "__rainning_projectiles", + "__rainning_projectiles", + "__create_spike", + ], [ "__rainning_projectiles", "__rainning_projectiles", @@ -137,6 +149,12 @@ class Wave: ] +class HorizontalProjectiles: + """ + Composant qui marque les entitées comme etnat des projectiles horizontaux + """ + + def __initialize_world(world: World): """ TODO @@ -151,6 +169,7 @@ def __initialize_world(world: World): ) world.new_entity().set(Coroutine(__wave(world))) + world.new_entity().set(Coroutine(__print_time(world))) world.new_entity().set(Sprite(world[Assets].get_texture("background"))) @@ -231,7 +250,7 @@ def __check_hurt(world: World): position = entity.get(Sprite).position width, height = entity.get(Sprite).texture.get_size() - for shield in world.query(Velocity, Sprite): + for shield in world.query(Player, Sprite): if world[Hurtable] == Hurtable.TRUE: shield_position = shield.get(Sprite).position shield_width, shield_height = shield.get(Sprite).texture.get_size() @@ -258,7 +277,6 @@ def __check_hurt(world: World): ) if is_collision: world.set(Life(world.get(Life) - entity.get(Hurt).damage)) - print(world.get(Life)) entity.remove(Hurt) if Spike in entity: match entity.get(Spike): @@ -294,26 +312,88 @@ def __defeat(world: World): def __wave(world: World): + entity = world.new_entity() + entity2 = world.new_entity() + entity3 = world.new_entity() + entity4 = world.new_entity() + entity5 = world.new_entity() for i, actuel_wave in enumerate(world[Wave].wave_list): print("vague n°" + str(i)) - for fonction in actuel_wave: - match fonction: - case "__rainning_projectiles": - print("1") - entity = world.new_entity() - entity.set(Coroutine(__rainning_projectiles(world))) - case "__create_zone_attack": - print("2") - entity = world.new_entity() - entity.set(Coroutine(__create_zone_attack(world))) - case "__create_spike": - entity = world.new_entity() - entity.set(Coroutine(__create_spike(world))) - case _: - pass + for i, fonction in enumerate(actuel_wave): + if i == 0: + match fonction: + case "__rainning_projectiles": + entity.set(Coroutine(__rainning_projectiles(world))) + case "__create_zone_attack": + for i in range(5): + entity.set(Coroutine(__create_zone_attack(world))) + yield wait(5) + case "__create_spike": + entity.set(Coroutine(__create_spike(world))) + yield wait(25) + entity4.set(Coroutine(__create_spike(world))) + case "__horizontal_projectile": + entity.set(Coroutine(__horizontal_projectile(world))) + case _: + pass + elif i == 1: + match fonction: + case "__rainning_projectiles": + entity2.set(Coroutine(__rainning_projectiles(world))) + case "__create_zone_attack": + for i in range(5): + entity2.set(Coroutine(__create_zone_attack(world))) + yield wait(5) + case "__create_spike": + entity2.set(Coroutine(__create_spike(world))) + yield wait(25) + entity2.set(Coroutine(__create_spike(world))) + case "__horizontal_projectile": + entity2.set(Coroutine(__horizontal_projectile(world))) + case _: + pass + elif i == 2: + match fonction: + case "__rainning_projectiles": + entity3.set(Coroutine(__rainning_projectiles(world))) + case "__create_zone_attack": + for i in range(5): + entity3.set(Coroutine(__create_zone_attack(world))) + yield wait(5) + case "__create_spike": + entity3.set(Coroutine(__create_spike(world))) + yield wait(25) + entity3.set(Coroutine(__create_spike(world))) + case "__horizontal_projectile": + entity3.set(Coroutine(__horizontal_projectile(world))) + case _: + pass + elif i == 3: + match fonction: + case "__rainning_projectiles": + entity4.set(Coroutine(__rainning_projectiles(world))) + case "__create_zone_attack": + for i in range(5): + entity4.set(Coroutine(__create_zone_attack(world))) + yield wait(5) + case "__create_spike": + entity4.set(Coroutine(__create_spike(world))) + yield wait(25) + entity4.set(Coroutine(__create_spike(world))) + case "__horizontal_projectile": + entity4.set(Coroutine(__horizontal_projectile(world))) + case _: + pass + yield wait(float(world[Wave].wave_list[-1][0])) entity.destroy() - for entities in world.query(RainProjectiles): + entity2.destroy() + entity3.destroy() + entity4.destroy() + entity5.destroy() + for entities in world.query( + RainProjectiles or ZoneAttack or Spike or HorizontalProjectiles + ): entities.destroy() @@ -402,6 +482,8 @@ def __create_zone_attack(world: World): world[FightBox].p2[1], ) locate = locate2 + for entities in world.query(ZoneAttackProjectiles): + entities.destroy() def __create_spike(world: World): @@ -546,9 +628,36 @@ def __rainning_projectiles(world: World): yield wait(0.2) entity.set(smooth.Target(Vec2(entity[Sprite].position.x, 1121))) - for entity in world.query(RainProjectiles, Sprite): - if entity[Sprite].position.y > 1080: - entity.destroy() + for entity in world.query(RainProjectiles, Sprite): + if entity[Sprite].position.y > 1080: + entity.destroy() + + +def __horizontal_projectile(world: World): + while IsRunning: + animation = Animation( + "projectiles_coming", + 30, + ) + entity = world.new_entity() + entity.set( + Sprite( + world[Assets].get_texture("error"), + Vec2(10, random.randint(500, 930)), + 4, + ), + animation, + smooth.Speed(2), + Hurt(10), + HorizontalProjectiles(), + ) + yield animation.wait() + yield wait(1) + entity.set(smooth.Target(Vec2(1500, entity[Sprite].position.y))) + + for entity in world.query(RainProjectiles, Sprite): + if entity[Sprite].position.x > 1440: + entity.destroy() def __check_key_pressed(world: World): @@ -573,6 +682,14 @@ def __update_life_bar(world: World): entity[Sprite].texture = surface_carre +def __print_time(world: World): + time = 0 + while IsRunning: + yield wait(1) + time += 1 + print(time) + + def __new_game_scene() -> Scene: """ Créer une nouvelle scène