From e5cc379bbfcca8dffb4dbeb5d38e6b12c5b146ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl?= Date: Sat, 4 Nov 2023 19:33:13 +0100 Subject: [PATCH] =?UTF-8?q?Ajout=20des=20spike=20sur=20le=20cot=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/scenes/story/boss_fight.py | 58 ++++++++++++++++++++++++++++++++-- 1 file changed, 55 insertions(+), 3 deletions(-) diff --git a/src/scenes/story/boss_fight.py b/src/scenes/story/boss_fight.py index 407bac9..6831201 100644 --- a/src/scenes/story/boss_fight.py +++ b/src/scenes/story/boss_fight.py @@ -4,6 +4,8 @@ Scene de Combat final contre edmond, inspiré du combat d'omega flowey dans unde from enum import Enum import random +from tkinter import RIGHT +from turtle import down, left, right from engine import CurrentScene, Scene from engine.ecs import World @@ -77,6 +79,8 @@ class Spike(Enum): UP = 0 DOWN = 1 + LEFT = 2 + RIGHT = 3 class Hurtable(Enum): @@ -180,7 +184,15 @@ def __check_hurt(world: World): print(world.get(Life)) entity.remove(Hurt) if Spike in entity: - text = "up" if entity.get(Spike) == Spike.UP else "down" + match entity.get(Spike): + case Spike.UP: + text = "up" + case Spike.DOWN: + text = "down" + case Spike.LEFT: + text = "left" + case Spike.RIGHT: + text = "right" entity.set( Animation( "spike/spike_" + text + "_leaving", @@ -298,7 +310,7 @@ def __create_spike(world: World, time: float): Sprite( world[Assets].get_texture("error"), Vec2(world[FightBox].p1[0], world[FightBox].p1[1]), - 2, + 3, ), Spike(0), Animation( @@ -317,7 +329,7 @@ def __create_spike(world: World, time: float): Sprite( world[Assets].get_texture("error"), Vec2(world[FightBox].p1[0], world[FightBox].p2[1] - 143), - 2, + 3, ), Spike(1), Animation( @@ -331,10 +343,50 @@ def __create_spike(world: World, time: float): ), ) + 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(time) top_spike.destroy() down_spike.destroy() + left_spike.destroy() + right_spike.destroy() def __check_key_pressed(world: World):