From c3e3c520e2b1c1bed285f8e200b57bf0baabf514 Mon Sep 17 00:00:00 2001 From: Tipragot Date: Sun, 5 Nov 2023 17:31:28 +0100 Subject: [PATCH] DADADADA --- src/scenes/story/boss_fight.py | 247 +++++++++++++++------------------ 1 file changed, 112 insertions(+), 135 deletions(-) diff --git a/src/scenes/story/boss_fight.py b/src/scenes/story/boss_fight.py index 19bed97..359ee2f 100644 --- a/src/scenes/story/boss_fight.py +++ b/src/scenes/story/boss_fight.py @@ -13,7 +13,7 @@ from engine.math import Vec2 from plugins import assets, smooth from plugins import render from plugins.animation import Animation -from plugins.inputs import Held, Pressed +from plugins.inputs import Held from plugins.render import Sprite from plugins.assets import Assets from plugins.coroutine import condition, wait, Coroutine @@ -118,16 +118,17 @@ class Wave: def __init__(self) -> None: self.wave_list = [ ["rainning"], - ["horizontal_left"], + ["rainning", "rainning"], ["rainning", "horizontal_left"], - ["rainning", "horizontal_right"], - ["rainning", "zones"], - ["rainning", "horizontal_left", "zones"], - ["rainning", "spikes"], - ["rainning", "horizontal_left", "horizontal_right"], - ["rainning", "horizontal_right", "zones"], + ["horizontal_left", "horizontal_right"], + ["rainning", "rainning", "zones"], + ["rainning", "rainning", "horizontal_left", "zones"], + ["rainning", "rainning", "spikes"], + ["rainning", "horizontal_left", "horizontal_right", "zones"], ["rainning", "spikes", "zones"], - ["rainning", "horizontal", "zones"], + ["rainning", "horizontal_left", "horizontal_right", "zones"], + ["rainning", "spikes", "zones"], + ["rainning", "horizontal_left", "horizontal_right", "zones"], ["rainning", "spikes", "zones"], ] @@ -152,7 +153,6 @@ 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"))) @@ -446,119 +446,117 @@ def __create_zone_attack(world: World, number: int = 2): locate = locate2 -def __create_spike(world: World, number: int = 1): +def __create_spike(world: World): """ TODO """ - for _ in range(number): - 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, - ), - ) + 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() + yield wait(2.0) + temp_warning_spike.destroy() - top_spike = world.new_entity() - top_spike.set( - Sprite( - world[Assets].get_texture("spike/spike_up_coming/0000"), - Vec2(world[FightBox].p1[0], world[FightBox].p1[1]), - 3, + top_spike = world.new_entity() + top_spike.set( + Sprite( + world[Assets].get_texture("spike/spike_up_coming/0000"), + 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), ), - Spike(0), + ), + ) + + down_spike = world.new_entity() + down_spike.set( + Sprite( + world[Assets].get_texture("spike/spike_down_coming/0000"), + 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("spike/spike_left_coming/0000"), + 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("spike/spike_left_coming/0000"), + 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_up_coming", + "spike/spike_" + name + "_leaving", 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("spike/spike_down_coming/0000"), - 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("spike/spike_left_coming/0000"), - 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("spike/spike_left_coming/0000"), - 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(), - ) + callback=lambda world, entity: entity.destroy(), ) + ) class RainProjectiles(Vec2): @@ -623,18 +621,6 @@ def __horizontal_projectile(world: World, left: bool, number: int = 10): entity.destroy() -def __check_key_pressed(world: World): - """ - TODO - """ - pressed = world[Pressed] - for keys in pressed: - if keys == "a": - world.new_entity().set(Coroutine(__create_zone_attack(world))) - if keys == "e": - world.new_entity().set(Coroutine(__create_spike(world))) - - def __update_life_bar(world: World): for entity in world.query(LifeBar): if world[Life] == 0: @@ -645,14 +631,6 @@ 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 @@ -662,7 +640,6 @@ def __new_game_scene() -> Scene: [__initialize_world], [ __move, - __check_key_pressed, __check_hurt, __defeat, ],