Ajout des spike sur le coté

This commit is contained in:
Raphaël 2023-11-04 19:33:13 +01:00
parent 4aa04ce8f2
commit e5cc379bbf

View file

@ -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):