Ajout rainning projectiles

This commit is contained in:
Raphaël 2023-11-04 21:06:58 +01:00
parent 1e26bc2851
commit bd7176e791
3 changed files with 68 additions and 7 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

View file

@ -5,7 +5,7 @@ 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 tkinter import RIGHT
from turtle import down, left, right from turtle import down, left, right, shapesize
from engine import CurrentScene, Scene from engine import CurrentScene, Scene
from engine.ecs import World from engine.ecs import World
@ -92,14 +92,26 @@ class Hurtable(Enum):
FALSE = 1 FALSE = 1
class IsRunning:
"""
Ressource qui definit si le jeux est en cours
"""
def __initialize_world(world: World): def __initialize_world(world: World):
""" """
TODO TODO
""" """
world.set( world.set(
ShieldPos(Vec2(render.WIDTH / 2, 750)), FightBox(), Life(100), Hurtable.TRUE ShieldPos(Vec2(render.WIDTH / 2, 750)),
FightBox(),
Life(100),
Hurtable.TRUE,
IsRunning(),
) )
world.new_entity().set(Coroutine(__rainning_projectiles(world)))
world.new_entity().set(Sprite(world[Assets].get_texture("background"))) world.new_entity().set(Sprite(world[Assets].get_texture("background")))
world.new_entity().set( world.new_entity().set(
@ -211,6 +223,7 @@ def __defeat(world: World):
TODO TODO
""" """
if world[Life] <= 0: if world[Life] <= 0:
world.remove(IsRunning)
world[CurrentScene] = __new_game_scene() world[CurrentScene] = __new_game_scene()
@ -384,10 +397,53 @@ def __create_spike(world: World, time: float):
yield wait(time) yield wait(time)
top_spike.destroy() top_spike.set(
down_spike.destroy() Animation(
left_spike.destroy() "spike/spike_up_leaving",
right_spike.destroy() 30,
callback=lambda world, entity: entity.destroy(),
)
)
down_spike.set(
Animation(
"spike/spike_down_leaving",
30,
callback=lambda world, entity: entity.destroy(),
)
)
left_spike.set(
Animation(
"spike/spike_left_leaving",
30,
callback=lambda world, entity: entity.destroy(),
)
)
right_spike.set(
Animation(
"spike/spike_right_leaving",
30,
callback=lambda world, entity: entity.destroy(),
)
)
def __rainning_projectiles(world: World):
while IsRunning:
entity = world.new_entity()
entity.set(
Sprite(
world[Assets].get_texture("error"),
Vec2(random.randint(0, 1399), 300),
4,
),
Animation("projectiles", 60, True),
smooth.Speed(1.3),
Hurt(10),
)
entity.set(smooth.Target(Vec2(entity[Sprite].position.x, 1121)))
yield wait(0.5)
if entity[Sprite].position.y >= 1080:
entity.destroy()
def __check_key_pressed(world: World): def __check_key_pressed(world: World):
@ -409,7 +465,12 @@ def __new_game_scene() -> Scene:
return ( return (
Scene( Scene(
[__initialize_world], [__initialize_world],
[__move, __check_key_pressed, __check_hurt, __defeat], [
__move,
__check_key_pressed,
__check_hurt,
__defeat,
],
[], [],
) )
+ smooth.PLUGIN + smooth.PLUGIN