Ajout des spike sur le coté
This commit is contained in:
parent
4aa04ce8f2
commit
e5cc379bbf
|
@ -4,6 +4,8 @@ Scene de Combat final contre edmond, inspiré du combat d'omega flowey dans unde
|
||||||
|
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
import random
|
import random
|
||||||
|
from tkinter import RIGHT
|
||||||
|
from turtle import down, left, right
|
||||||
|
|
||||||
from engine import CurrentScene, Scene
|
from engine import CurrentScene, Scene
|
||||||
from engine.ecs import World
|
from engine.ecs import World
|
||||||
|
@ -77,6 +79,8 @@ class Spike(Enum):
|
||||||
|
|
||||||
UP = 0
|
UP = 0
|
||||||
DOWN = 1
|
DOWN = 1
|
||||||
|
LEFT = 2
|
||||||
|
RIGHT = 3
|
||||||
|
|
||||||
|
|
||||||
class Hurtable(Enum):
|
class Hurtable(Enum):
|
||||||
|
@ -180,7 +184,15 @@ def __check_hurt(world: World):
|
||||||
print(world.get(Life))
|
print(world.get(Life))
|
||||||
entity.remove(Hurt)
|
entity.remove(Hurt)
|
||||||
if Spike in entity:
|
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(
|
entity.set(
|
||||||
Animation(
|
Animation(
|
||||||
"spike/spike_" + text + "_leaving",
|
"spike/spike_" + text + "_leaving",
|
||||||
|
@ -298,7 +310,7 @@ def __create_spike(world: World, time: float):
|
||||||
Sprite(
|
Sprite(
|
||||||
world[Assets].get_texture("error"),
|
world[Assets].get_texture("error"),
|
||||||
Vec2(world[FightBox].p1[0], world[FightBox].p1[1]),
|
Vec2(world[FightBox].p1[0], world[FightBox].p1[1]),
|
||||||
2,
|
3,
|
||||||
),
|
),
|
||||||
Spike(0),
|
Spike(0),
|
||||||
Animation(
|
Animation(
|
||||||
|
@ -317,7 +329,7 @@ def __create_spike(world: World, time: float):
|
||||||
Sprite(
|
Sprite(
|
||||||
world[Assets].get_texture("error"),
|
world[Assets].get_texture("error"),
|
||||||
Vec2(world[FightBox].p1[0], world[FightBox].p2[1] - 143),
|
Vec2(world[FightBox].p1[0], world[FightBox].p2[1] - 143),
|
||||||
2,
|
3,
|
||||||
),
|
),
|
||||||
Spike(1),
|
Spike(1),
|
||||||
Animation(
|
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)
|
yield wait(time)
|
||||||
|
|
||||||
top_spike.destroy()
|
top_spike.destroy()
|
||||||
down_spike.destroy()
|
down_spike.destroy()
|
||||||
|
left_spike.destroy()
|
||||||
|
right_spike.destroy()
|
||||||
|
|
||||||
|
|
||||||
def __check_key_pressed(world: World):
|
def __check_key_pressed(world: World):
|
||||||
|
|
Loading…
Reference in a new issue