diff --git a/assets/story/boss_fight/death.mp3 b/assets/story/boss_fight/death.mp3 new file mode 100644 index 0000000..22092c6 Binary files /dev/null and b/assets/story/boss_fight/death.mp3 differ diff --git a/src/scenes/menu.py b/src/scenes/menu.py index aa550c4..071b087 100644 --- a/src/scenes/menu.py +++ b/src/scenes/menu.py @@ -48,7 +48,7 @@ def __on_click_butons(world: World, _entity: Entity, name: str): case "tricheur": world[CurrentScene] = base_game.CHEATER case "histoire": - world[CurrentScene] = directory_search.SCENE + world[CurrentScene] = boss_fight.SCENE case _: pass diff --git a/src/scenes/story/boss_fight.py b/src/scenes/story/boss_fight.py index bb7aab0..25ddfec 100644 --- a/src/scenes/story/boss_fight.py +++ b/src/scenes/story/boss_fight.py @@ -13,10 +13,11 @@ from engine.math import Vec2 from plugins import assets, smooth from plugins import render from plugins.animation import Animation -from plugins.inputs import Held +from plugins.inputs import Held, MousePosition from plugins.render import Sprite from plugins.assets import Assets from plugins.coroutine import condition, wait, Coroutine +from plugins.sound import Sound from plugins.timing import Delta, TimedEvent @@ -189,9 +190,29 @@ def __move(world: World): """ TODO """ + if IsRunning not in world: + return held = world[Held] s_pos = world[ShieldPos] for entity in world.query(Sprite, Velocity): + if "button_1" in held: + world[ShieldPos] += ( + (world[MousePosition] - world[ShieldPos]).normalized + * entity[Velocity] + * world[Delta] + ) + box = world[FightBox] + if world[ShieldPos].x < box.p1[0] + 37: + world[ShieldPos].x = box.p1[0] + 37 + if world[ShieldPos].x > box.p2[0] - 37: + world[ShieldPos].x = box.p2[0] - 37 + if world[ShieldPos].y < box.p1[1] + 45.5: + world[ShieldPos].y = box.p1[1] + 45.5 + if world[ShieldPos].y > box.p2[1] - 45.5: + world[ShieldPos].y = box.p2[1] - 45.5 + entity[smooth.Target] = world[ShieldPos] + continue + for key in held: if key in ("up", "z"): if ( @@ -241,6 +262,8 @@ def __check_hurt(world: World): """ TODO """ + if IsRunning not in world: + return for entity in world.query(Hurt, Sprite): position = entity.get(Sprite).position width, height = entity.get(Sprite).texture.get_size() @@ -303,15 +326,21 @@ def __defeat(world: World): """ TODO """ - if world[Life] <= 0: + if world[Life] <= 0 and IsRunning in world: world.remove(IsRunning) - world[CurrentScene] = __new_game_scene() - - -class AWave: - """ - TODO - """ + for entity in world.query(Player): + print("ANIMATIONS") + entity.set( + Animation( + "explosion", + 24, + ), + Sound(world[Assets].get_sound("death")), + ) + entity.remove(smooth.Target) + for entity in world.query(without=(Player,)): + entity.destroy() + world.new_entity().set(Sprite(world[Assets].get_texture("background"))) def __wave(world: World): @@ -323,28 +352,26 @@ def __wave(world: World): case "rainning": entity = world.new_entity() entities.append(entity) - entity.set(AWave(), Coroutine(__rainning_projectiles(world))) + entity.set(Coroutine(__rainning_projectiles(world))) case "zones": entity = world.new_entity() entities.append(entity) - entity.set(AWave(), Coroutine(__create_zone_attack(world))) + entity.set(Coroutine(__create_zone_attack(world))) case "spikes": entity = world.new_entity() entities.append(entity) - entity.set(AWave(), Coroutine(__create_spike(world))) + entity.set(Coroutine(__create_spike(world))) case "horizontal_left": entity = world.new_entity() entities.append(entity) - entity.set(AWave(), Coroutine(__horizontal_projectile(world, True))) + entity.set(Coroutine(__horizontal_projectile(world, True))) case "horizontal_right": entity = world.new_entity() entities.append(entity) - entity.set( - AWave(), Coroutine(__horizontal_projectile(world, False)) - ) + entity.set(Coroutine(__horizontal_projectile(world, False))) case _: pass yield wait(0.5) @@ -602,7 +629,7 @@ def __horizontal_projectile(world: World, left: bool, number: int = 10): entity.set( HorizontalProjectiles(), Sprite( - world[Assets].get_texture("error"), + world[Assets].get_texture("projectiles_coming/0000"), Vec2(10 if left else render.WIDTH - 10, random.randint(500, 889)), 4, ), diff --git a/src/scenes/story/directory_search.py b/src/scenes/story/directory_search.py index 83e4fda..2fc4539 100644 --- a/src/scenes/story/directory_search.py +++ b/src/scenes/story/directory_search.py @@ -16,6 +16,7 @@ from plugins.assets import Assets from plugins.render import Sprite from plugins.sound import Sound from plugins.text import Text +from scenes.story import boss_fight LINES = 3 @@ -185,7 +186,10 @@ def __game_loop(world: World): yield wait(5.0 - (i * 0.4)) __spawn_search_directory(world) yield wait(5.0) - print("BRABO BG !") + + # On passe a la scène de jeu (TEMP) + yield wait(5.0) + world[CurrentScene] = boss_fight.SCENE def __spawn_search_alerts(world: World, nb_alerts: int):