diff --git a/src/scenes/story/boss_fight.py b/src/scenes/story/boss_fight.py index 1b57698..3ec6aec 100644 --- a/src/scenes/story/boss_fight.py +++ b/src/scenes/story/boss_fight.py @@ -117,7 +117,7 @@ class Wave: def __init__(self) -> None: self.wave_list = [ - ["__rainning_projectiles"], + ["__rainning_projectiles", "__create_zone_attack"], ["__rainning_projectiles", "__horizontal_projectile"], [ "__rainning_projectiles", @@ -323,86 +323,39 @@ def __defeat(world: World): world[CurrentScene] = __new_game_scene() +class AWave: + """ + TODO + """ + + 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 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 + match fonction: + case "__rainning_projectiles": + world.new_entity().set( + AWave(), Coroutine(__rainning_projectiles(world)) + ) + case "__create_zone_attack": + world.new_entity().set( + AWave(), Coroutine(__create_zone_attack(world)) + ) + + case "__create_spike": + world.new_entity().set(AWave(), Coroutine(__create_spike(world))) + + case "__horizontal_projectile": + world.new_entity().set( + AWave(), Coroutine(__horizontal_projectile(world)) + ) + case _: + pass yield wait(float(world[Wave].wave_list[-1][0])) - entity.destroy() - entity2.destroy() - entity3.destroy() - entity4.destroy() - entity5.destroy() + for entity_to_destroy in world.query(AWave): + entity_to_destroy.destroy() for entities in world.query( RainProjectiles or ZoneAttack or Spike or HorizontalProjectiles ): @@ -410,68 +363,27 @@ def __wave(world: World): def __create_zone_attack(world: World): - """ - TODO - """ - double = random.randint(1, 10) - locate = random.randint(0, 2) - if double != 10: - animation = Animation("zone_attack", 60) - entity = world.new_entity() - entity.set( - Sprite( - world[Assets].get_texture("error"), - Vec2((locate * 413) + world[FightBox].p1[0], world[FightBox].p1[1]), - 1, - ), - animation, - ZoneAttack(), - ) - yield animation.wait() - entity.destroy() - for i in range(10): - projectiles = world.new_entity() - - projectiles.set( + for _ in range(5): + yield wait(5) + """ + TODO + """ + double = random.randint(1, 10) + locate = random.randint(0, 2) + if double != 10: + animation = Animation("zone_attack", 60) + entity = world.new_entity() + entity.set( Sprite( world[Assets].get_texture("error"), - Vec2( - i * 41 + world[FightBox].p1[0] + (locate * 413), - world[FightBox].p1[1], - ), - 2, - ), - Animation("projectiles", 60, True), - ZoneAttackProjectiles(), - Hurt(10), - TimedEvent(0.4, lambda world, entity: entity.destroy()), - ) - projectiles[smooth.Target] = Vec2( - i * 41 + world[FightBox].p1[0] + (locate * 413), world[FightBox].p2[1] - ) - - else: - locate2 = locate - for _zone in range(2): - world.new_entity().set( - Sprite( - world[Assets].get_texture("error"), - Vec2( - (locate * 413) + world[FightBox].p1[0], - world[FightBox].p1[1], - ), + Vec2((locate * 413) + world[FightBox].p1[0], world[FightBox].p1[1]), 1, ), - Animation("zone_attack", 60), + animation, ZoneAttack(), ) - - while locate == locate2: - locate = random.randint(0, 2) - yield wait(1.75) - for entity in world.query(ZoneAttack): + yield animation.wait() entity.destroy() - for _z in range(2): for i in range(10): projectiles = world.new_entity() @@ -493,124 +405,167 @@ def __create_zone_attack(world: World): i * 41 + world[FightBox].p1[0] + (locate * 413), world[FightBox].p2[1], ) - locate = locate2 - for entities in world.query(ZoneAttackProjectiles): - entities.destroy() + + else: + locate2 = locate + for _zone in range(2): + world.new_entity().set( + Sprite( + world[Assets].get_texture("error"), + Vec2( + (locate * 413) + world[FightBox].p1[0], + world[FightBox].p1[1], + ), + 1, + ), + Animation("zone_attack", 60), + ZoneAttack(), + ) + + while locate == locate2: + locate = random.randint(0, 2) + yield wait(1.75) + for entity in world.query(ZoneAttack): + entity.destroy() + for _z in range(2): + for i in range(10): + projectiles = world.new_entity() + + projectiles.set( + Sprite( + world[Assets].get_texture("error"), + Vec2( + i * 41 + world[FightBox].p1[0] + (locate * 413), + world[FightBox].p1[1], + ), + 2, + ), + Animation("projectiles", 60, True), + ZoneAttackProjectiles(), + Hurt(10), + TimedEvent(0.4, lambda world, entity: entity.destroy()), + ) + projectiles[smooth.Target] = Vec2( + i * 41 + world[FightBox].p1[0] + (locate * 413), + world[FightBox].p2[1], + ) + locate = locate2 def __create_spike(world: World): """ TODO """ - - temp_warning_spike = world.new_entity() - temp_warning_spike.set( - Sprite( - world[Assets].get_texture("warning_spike"), - Vec2(world[FightBox].p1[0], world[FightBox].p1[1]), - 3, - ), - ) - - yield wait(2.0) - temp_warning_spike.destroy() - - top_spike = world.new_entity() - top_spike.set( - Sprite( - world[Assets].get_texture("error"), - Vec2(world[FightBox].p1[0], world[FightBox].p1[1]), - 3, - ), - Spike(0), - Animation( - "spike/spike_up_coming", - 30, - True, - callback=lambda _world, entity: entity.set( - Animation("spike/spike_up", 30, True), - Hurt(20), + for _ in range(2): + yield wait(15.0) + temp_warning_spike = world.new_entity() + temp_warning_spike.set( + Sprite( + world[Assets].get_texture("warning_spike"), + Vec2(world[FightBox].p1[0], world[FightBox].p1[1]), + 3, ), - ), - ) - - down_spike = world.new_entity() - down_spike.set( - Sprite( - world[Assets].get_texture("error"), - Vec2(world[FightBox].p1[0], world[FightBox].p2[1] - 143), - 3, - ), - Spike(1), - Animation( - "spike/spike_down_coming", - 30, - True, - callback=lambda _world, entity: entity.set( - Animation("spike/spike_down", 30, True), - Hurt(20), - ), - ), - ) - - left_spike = world.new_entity() - left_spike.set( - Sprite( - world[Assets].get_texture("error"), - Vec2(world[FightBox].p1[0], world[FightBox].p1[1]), - 2, - ), - Spike(2), - Animation( - "spike/spike_left_coming", - 30, - True, - callback=lambda _world, entity: entity.set( - Animation("spike/spike_left", 30, True), - Hurt(20), - ), - ), - ) - - right_spike = world.new_entity() - right_spike.set( - Sprite( - world[Assets].get_texture("error"), - Vec2(world[FightBox].p2[0] - 50, world[FightBox].p1[1]), - 2, - ), - Spike(3), - Animation( - "spike/spike_right_coming", - 30, - True, - callback=lambda _world, entity: entity.set( - Animation("spike/spike_right", 30, True), - Hurt(20), - ), - ), - ) - - yield wait(5) - - for spike in world.query(Spike): - match spike.get(Spike): - case Spike.UP: - name = "up" - case Spike.DOWN: - name = "down" - case Spike.LEFT: - name = "left" - case Spike.RIGHT: - name = "right" - spike.set( - Animation( - "spike/spike_" + name + "_leaving", - 30, - callback=lambda world, entity: entity.destroy(), - ) ) + yield wait(2.0) + temp_warning_spike.destroy() + + top_spike = world.new_entity() + top_spike.set( + Sprite( + world[Assets].get_texture("error"), + Vec2(world[FightBox].p1[0], world[FightBox].p1[1]), + 3, + ), + Spike(0), + Animation( + "spike/spike_up_coming", + 30, + True, + callback=lambda _world, entity: entity.set( + Animation("spike/spike_up", 30, True), + Hurt(20), + ), + ), + ) + + down_spike = world.new_entity() + down_spike.set( + Sprite( + world[Assets].get_texture("error"), + Vec2(world[FightBox].p1[0], world[FightBox].p2[1] - 143), + 3, + ), + Spike(1), + Animation( + "spike/spike_down_coming", + 30, + True, + callback=lambda _world, entity: entity.set( + Animation("spike/spike_down", 30, True), + Hurt(20), + ), + ), + ) + + left_spike = world.new_entity() + left_spike.set( + Sprite( + world[Assets].get_texture("error"), + Vec2(world[FightBox].p1[0], world[FightBox].p1[1]), + 2, + ), + Spike(2), + Animation( + "spike/spike_left_coming", + 30, + True, + callback=lambda _world, entity: entity.set( + Animation("spike/spike_left", 30, True), + Hurt(20), + ), + ), + ) + + right_spike = world.new_entity() + right_spike.set( + Sprite( + world[Assets].get_texture("error"), + Vec2(world[FightBox].p2[0] - 50, world[FightBox].p1[1]), + 2, + ), + Spike(3), + Animation( + "spike/spike_right_coming", + 30, + True, + callback=lambda _world, entity: entity.set( + Animation("spike/spike_right", 30, True), + Hurt(20), + ), + ), + ) + + yield wait(5) + + for spike in world.query(Spike): + match spike.get(Spike): + case Spike.UP: + name = "up" + case Spike.DOWN: + name = "down" + case Spike.LEFT: + name = "left" + case Spike.RIGHT: + name = "right" + spike.set( + Animation( + "spike/spike_" + name + "_leaving", + 30, + callback=lambda world, entity: entity.destroy(), + ) + ) + class RainProjectiles(Vec2): """ @@ -653,6 +608,7 @@ def __horizontal_projectile(world: World): ) entity = world.new_entity() entity.set( + HorizontalProjectiles(), Sprite( world[Assets].get_texture("error"), Vec2(10, random.randint(500, 930)), @@ -661,13 +617,12 @@ def __horizontal_projectile(world: World): 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): + for entity in world.query(HorizontalProjectiles, Sprite): if entity[Sprite].position.x > 1440: entity.destroy()