fix apparition de projectiles de zone

This commit is contained in:
CoCo_Sol 2023-11-05 14:49:29 +01:00
parent acaf9475a5
commit 4b2b6ea89c

View file

@ -117,7 +117,7 @@ class Wave:
def __init__(self) -> None: def __init__(self) -> None:
self.wave_list = [ self.wave_list = [
["__rainning_projectiles"], ["__rainning_projectiles", "__create_zone_attack"],
["__rainning_projectiles", "__horizontal_projectile"], ["__rainning_projectiles", "__horizontal_projectile"],
[ [
"__rainning_projectiles", "__rainning_projectiles",
@ -323,86 +323,39 @@ def __defeat(world: World):
world[CurrentScene] = __new_game_scene() world[CurrentScene] = __new_game_scene()
class AWave:
"""
TODO
"""
def __wave(world: World): def __wave(world: World):
entity = world.new_entity()
entity2 = world.new_entity()
entity3 = world.new_entity()
entity4 = world.new_entity()
entity5 = world.new_entity()
for i, actuel_wave in enumerate(world[Wave].wave_list): for i, actuel_wave in enumerate(world[Wave].wave_list):
print("vague n°" + str(i)) print("vague n°" + str(i))
for i, fonction in enumerate(actuel_wave): for i, fonction in enumerate(actuel_wave):
if i == 0:
match fonction: match fonction:
case "__rainning_projectiles": case "__rainning_projectiles":
entity.set(Coroutine(__rainning_projectiles(world))) world.new_entity().set(
AWave(), Coroutine(__rainning_projectiles(world))
)
case "__create_zone_attack": case "__create_zone_attack":
for i in range(5): world.new_entity().set(
entity.set(Coroutine(__create_zone_attack(world))) AWave(), Coroutine(__create_zone_attack(world))
yield wait(5) )
case "__create_spike": case "__create_spike":
entity.set(Coroutine(__create_spike(world))) world.new_entity().set(AWave(), Coroutine(__create_spike(world)))
yield wait(25)
entity4.set(Coroutine(__create_spike(world)))
case "__horizontal_projectile": case "__horizontal_projectile":
entity.set(Coroutine(__horizontal_projectile(world))) world.new_entity().set(
case _: AWave(), Coroutine(__horizontal_projectile(world))
pass )
elif i == 1:
match fonction:
case "__rainning_projectiles":
entity2.set(Coroutine(__rainning_projectiles(world)))
case "__create_zone_attack":
for i in range(5):
entity2.set(Coroutine(__create_zone_attack(world)))
yield wait(5)
case "__create_spike":
entity2.set(Coroutine(__create_spike(world)))
yield wait(25)
entity2.set(Coroutine(__create_spike(world)))
case "__horizontal_projectile":
entity2.set(Coroutine(__horizontal_projectile(world)))
case _:
pass
elif i == 2:
match fonction:
case "__rainning_projectiles":
entity3.set(Coroutine(__rainning_projectiles(world)))
case "__create_zone_attack":
for i in range(5):
entity3.set(Coroutine(__create_zone_attack(world)))
yield wait(5)
case "__create_spike":
entity3.set(Coroutine(__create_spike(world)))
yield wait(25)
entity3.set(Coroutine(__create_spike(world)))
case "__horizontal_projectile":
entity3.set(Coroutine(__horizontal_projectile(world)))
case _:
pass
elif i == 3:
match fonction:
case "__rainning_projectiles":
entity4.set(Coroutine(__rainning_projectiles(world)))
case "__create_zone_attack":
for i in range(5):
entity4.set(Coroutine(__create_zone_attack(world)))
yield wait(5)
case "__create_spike":
entity4.set(Coroutine(__create_spike(world)))
yield wait(25)
entity4.set(Coroutine(__create_spike(world)))
case "__horizontal_projectile":
entity4.set(Coroutine(__horizontal_projectile(world)))
case _: case _:
pass pass
yield wait(float(world[Wave].wave_list[-1][0])) yield wait(float(world[Wave].wave_list[-1][0]))
entity.destroy() for entity_to_destroy in world.query(AWave):
entity2.destroy() entity_to_destroy.destroy()
entity3.destroy()
entity4.destroy()
entity5.destroy()
for entities in world.query( for entities in world.query(
RainProjectiles or ZoneAttack or Spike or HorizontalProjectiles RainProjectiles or ZoneAttack or Spike or HorizontalProjectiles
): ):
@ -410,6 +363,8 @@ def __wave(world: World):
def __create_zone_attack(world: World): def __create_zone_attack(world: World):
for _ in range(5):
yield wait(5)
""" """
TODO TODO
""" """
@ -447,7 +402,8 @@ def __create_zone_attack(world: World):
TimedEvent(0.4, lambda world, entity: entity.destroy()), TimedEvent(0.4, lambda world, entity: entity.destroy()),
) )
projectiles[smooth.Target] = Vec2( projectiles[smooth.Target] = Vec2(
i * 41 + world[FightBox].p1[0] + (locate * 413), world[FightBox].p2[1] i * 41 + world[FightBox].p1[0] + (locate * 413),
world[FightBox].p2[1],
) )
else: else:
@ -494,15 +450,14 @@ def __create_zone_attack(world: World):
world[FightBox].p2[1], world[FightBox].p2[1],
) )
locate = locate2 locate = locate2
for entities in world.query(ZoneAttackProjectiles):
entities.destroy()
def __create_spike(world: World): def __create_spike(world: World):
""" """
TODO TODO
""" """
for _ in range(2):
yield wait(15.0)
temp_warning_spike = world.new_entity() temp_warning_spike = world.new_entity()
temp_warning_spike.set( temp_warning_spike.set(
Sprite( Sprite(
@ -653,6 +608,7 @@ def __horizontal_projectile(world: World):
) )
entity = world.new_entity() entity = world.new_entity()
entity.set( entity.set(
HorizontalProjectiles(),
Sprite( Sprite(
world[Assets].get_texture("error"), world[Assets].get_texture("error"),
Vec2(10, random.randint(500, 930)), Vec2(10, random.randint(500, 930)),
@ -661,13 +617,12 @@ def __horizontal_projectile(world: World):
animation, animation,
smooth.Speed(2), smooth.Speed(2),
Hurt(10), Hurt(10),
HorizontalProjectiles(),
) )
yield animation.wait() yield animation.wait()
yield wait(1) yield wait(1)
entity.set(smooth.Target(Vec2(1500, entity[Sprite].position.y))) entity.set(smooth.Target(Vec2(1500, entity[Sprite].position.y)))
for entity in world.query(RainProjectiles, Sprite): for entity in world.query(HorizontalProjectiles, Sprite):
if entity[Sprite].position.x > 1440: if entity[Sprite].position.x > 1440:
entity.destroy() entity.destroy()