fix apparition de projectiles de zone
This commit is contained in:
parent
acaf9475a5
commit
4b2b6ea89c
|
@ -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":
|
world.new_entity().set(
|
||||||
entity.set(Coroutine(__rainning_projectiles(world)))
|
AWave(), Coroutine(__rainning_projectiles(world))
|
||||||
case "__create_zone_attack":
|
)
|
||||||
for i in range(5):
|
case "__create_zone_attack":
|
||||||
entity.set(Coroutine(__create_zone_attack(world)))
|
world.new_entity().set(
|
||||||
yield wait(5)
|
AWave(), Coroutine(__create_zone_attack(world))
|
||||||
case "__create_spike":
|
)
|
||||||
entity.set(Coroutine(__create_spike(world)))
|
|
||||||
yield wait(25)
|
case "__create_spike":
|
||||||
entity4.set(Coroutine(__create_spike(world)))
|
world.new_entity().set(AWave(), Coroutine(__create_spike(world)))
|
||||||
case "__horizontal_projectile":
|
|
||||||
entity.set(Coroutine(__horizontal_projectile(world)))
|
case "__horizontal_projectile":
|
||||||
case _:
|
world.new_entity().set(
|
||||||
pass
|
AWave(), Coroutine(__horizontal_projectile(world))
|
||||||
elif i == 1:
|
)
|
||||||
match fonction:
|
case _:
|
||||||
case "__rainning_projectiles":
|
pass
|
||||||
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 _:
|
|
||||||
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,68 +363,27 @@ def __wave(world: World):
|
||||||
|
|
||||||
|
|
||||||
def __create_zone_attack(world: World):
|
def __create_zone_attack(world: World):
|
||||||
"""
|
for _ in range(5):
|
||||||
TODO
|
yield wait(5)
|
||||||
"""
|
"""
|
||||||
double = random.randint(1, 10)
|
TODO
|
||||||
locate = random.randint(0, 2)
|
"""
|
||||||
if double != 10:
|
double = random.randint(1, 10)
|
||||||
animation = Animation("zone_attack", 60)
|
locate = random.randint(0, 2)
|
||||||
entity = world.new_entity()
|
if double != 10:
|
||||||
entity.set(
|
animation = Animation("zone_attack", 60)
|
||||||
Sprite(
|
entity = world.new_entity()
|
||||||
world[Assets].get_texture("error"),
|
entity.set(
|
||||||
Vec2((locate * 413) + world[FightBox].p1[0], world[FightBox].p1[1]),
|
|
||||||
1,
|
|
||||||
),
|
|
||||||
animation,
|
|
||||||
ZoneAttack(),
|
|
||||||
)
|
|
||||||
yield animation.wait()
|
|
||||||
entity.destroy()
|
|
||||||
for i in range(10):
|
|
||||||
projectiles = world.new_entity()
|
|
||||||
|
|
||||||
projectiles.set(
|
|
||||||
Sprite(
|
Sprite(
|
||||||
world[Assets].get_texture("error"),
|
world[Assets].get_texture("error"),
|
||||||
Vec2(
|
Vec2((locate * 413) + world[FightBox].p1[0], world[FightBox].p1[1]),
|
||||||
i * 41 + world[FightBox].p1[0] + (locate * 413),
|
|
||||||
world[FightBox].p1[1],
|
|
||||||
),
|
|
||||||
2,
|
|
||||||
),
|
|
||||||
Animation("projectiles", 60, True),
|
|
||||||
ZoneAttackProjectiles(),
|
|
||||||
Hurt(10),
|
|
||||||
TimedEvent(0.4, lambda world, entity: entity.destroy()),
|
|
||||||
)
|
|
||||||
projectiles[smooth.Target] = Vec2(
|
|
||||||
i * 41 + world[FightBox].p1[0] + (locate * 413), world[FightBox].p2[1]
|
|
||||||
)
|
|
||||||
|
|
||||||
else:
|
|
||||||
locate2 = locate
|
|
||||||
for _zone in range(2):
|
|
||||||
world.new_entity().set(
|
|
||||||
Sprite(
|
|
||||||
world[Assets].get_texture("error"),
|
|
||||||
Vec2(
|
|
||||||
(locate * 413) + world[FightBox].p1[0],
|
|
||||||
world[FightBox].p1[1],
|
|
||||||
),
|
|
||||||
1,
|
1,
|
||||||
),
|
),
|
||||||
Animation("zone_attack", 60),
|
animation,
|
||||||
ZoneAttack(),
|
ZoneAttack(),
|
||||||
)
|
)
|
||||||
|
yield animation.wait()
|
||||||
while locate == locate2:
|
|
||||||
locate = random.randint(0, 2)
|
|
||||||
yield wait(1.75)
|
|
||||||
for entity in world.query(ZoneAttack):
|
|
||||||
entity.destroy()
|
entity.destroy()
|
||||||
for _z in range(2):
|
|
||||||
for i in range(10):
|
for i in range(10):
|
||||||
projectiles = world.new_entity()
|
projectiles = world.new_entity()
|
||||||
|
|
||||||
|
@ -493,124 +405,167 @@ def __create_zone_attack(world: World):
|
||||||
i * 41 + world[FightBox].p1[0] + (locate * 413),
|
i * 41 + world[FightBox].p1[0] + (locate * 413),
|
||||||
world[FightBox].p2[1],
|
world[FightBox].p2[1],
|
||||||
)
|
)
|
||||||
locate = locate2
|
|
||||||
for entities in world.query(ZoneAttackProjectiles):
|
else:
|
||||||
entities.destroy()
|
locate2 = locate
|
||||||
|
for _zone in range(2):
|
||||||
|
world.new_entity().set(
|
||||||
|
Sprite(
|
||||||
|
world[Assets].get_texture("error"),
|
||||||
|
Vec2(
|
||||||
|
(locate * 413) + world[FightBox].p1[0],
|
||||||
|
world[FightBox].p1[1],
|
||||||
|
),
|
||||||
|
1,
|
||||||
|
),
|
||||||
|
Animation("zone_attack", 60),
|
||||||
|
ZoneAttack(),
|
||||||
|
)
|
||||||
|
|
||||||
|
while locate == locate2:
|
||||||
|
locate = random.randint(0, 2)
|
||||||
|
yield wait(1.75)
|
||||||
|
for entity in world.query(ZoneAttack):
|
||||||
|
entity.destroy()
|
||||||
|
for _z in range(2):
|
||||||
|
for i in range(10):
|
||||||
|
projectiles = world.new_entity()
|
||||||
|
|
||||||
|
projectiles.set(
|
||||||
|
Sprite(
|
||||||
|
world[Assets].get_texture("error"),
|
||||||
|
Vec2(
|
||||||
|
i * 41 + world[FightBox].p1[0] + (locate * 413),
|
||||||
|
world[FightBox].p1[1],
|
||||||
|
),
|
||||||
|
2,
|
||||||
|
),
|
||||||
|
Animation("projectiles", 60, True),
|
||||||
|
ZoneAttackProjectiles(),
|
||||||
|
Hurt(10),
|
||||||
|
TimedEvent(0.4, lambda world, entity: entity.destroy()),
|
||||||
|
)
|
||||||
|
projectiles[smooth.Target] = Vec2(
|
||||||
|
i * 41 + world[FightBox].p1[0] + (locate * 413),
|
||||||
|
world[FightBox].p2[1],
|
||||||
|
)
|
||||||
|
locate = locate2
|
||||||
|
|
||||||
|
|
||||||
def __create_spike(world: World):
|
def __create_spike(world: World):
|
||||||
"""
|
"""
|
||||||
TODO
|
TODO
|
||||||
"""
|
"""
|
||||||
|
for _ in range(2):
|
||||||
temp_warning_spike = world.new_entity()
|
yield wait(15.0)
|
||||||
temp_warning_spike.set(
|
temp_warning_spike = world.new_entity()
|
||||||
Sprite(
|
temp_warning_spike.set(
|
||||||
world[Assets].get_texture("warning_spike"),
|
Sprite(
|
||||||
Vec2(world[FightBox].p1[0], world[FightBox].p1[1]),
|
world[Assets].get_texture("warning_spike"),
|
||||||
3,
|
Vec2(world[FightBox].p1[0], world[FightBox].p1[1]),
|
||||||
),
|
3,
|
||||||
)
|
|
||||||
|
|
||||||
yield wait(2.0)
|
|
||||||
temp_warning_spike.destroy()
|
|
||||||
|
|
||||||
top_spike = world.new_entity()
|
|
||||||
top_spike.set(
|
|
||||||
Sprite(
|
|
||||||
world[Assets].get_texture("error"),
|
|
||||||
Vec2(world[FightBox].p1[0], world[FightBox].p1[1]),
|
|
||||||
3,
|
|
||||||
),
|
|
||||||
Spike(0),
|
|
||||||
Animation(
|
|
||||||
"spike/spike_up_coming",
|
|
||||||
30,
|
|
||||||
True,
|
|
||||||
callback=lambda _world, entity: entity.set(
|
|
||||||
Animation("spike/spike_up", 30, True),
|
|
||||||
Hurt(20),
|
|
||||||
),
|
),
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
down_spike = world.new_entity()
|
|
||||||
down_spike.set(
|
|
||||||
Sprite(
|
|
||||||
world[Assets].get_texture("error"),
|
|
||||||
Vec2(world[FightBox].p1[0], world[FightBox].p2[1] - 143),
|
|
||||||
3,
|
|
||||||
),
|
|
||||||
Spike(1),
|
|
||||||
Animation(
|
|
||||||
"spike/spike_down_coming",
|
|
||||||
30,
|
|
||||||
True,
|
|
||||||
callback=lambda _world, entity: entity.set(
|
|
||||||
Animation("spike/spike_down", 30, True),
|
|
||||||
Hurt(20),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
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(5)
|
|
||||||
|
|
||||||
for spike in world.query(Spike):
|
|
||||||
match spike.get(Spike):
|
|
||||||
case Spike.UP:
|
|
||||||
name = "up"
|
|
||||||
case Spike.DOWN:
|
|
||||||
name = "down"
|
|
||||||
case Spike.LEFT:
|
|
||||||
name = "left"
|
|
||||||
case Spike.RIGHT:
|
|
||||||
name = "right"
|
|
||||||
spike.set(
|
|
||||||
Animation(
|
|
||||||
"spike/spike_" + name + "_leaving",
|
|
||||||
30,
|
|
||||||
callback=lambda world, entity: entity.destroy(),
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
yield wait(2.0)
|
||||||
|
temp_warning_spike.destroy()
|
||||||
|
|
||||||
|
top_spike = world.new_entity()
|
||||||
|
top_spike.set(
|
||||||
|
Sprite(
|
||||||
|
world[Assets].get_texture("error"),
|
||||||
|
Vec2(world[FightBox].p1[0], world[FightBox].p1[1]),
|
||||||
|
3,
|
||||||
|
),
|
||||||
|
Spike(0),
|
||||||
|
Animation(
|
||||||
|
"spike/spike_up_coming",
|
||||||
|
30,
|
||||||
|
True,
|
||||||
|
callback=lambda _world, entity: entity.set(
|
||||||
|
Animation("spike/spike_up", 30, True),
|
||||||
|
Hurt(20),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
down_spike = world.new_entity()
|
||||||
|
down_spike.set(
|
||||||
|
Sprite(
|
||||||
|
world[Assets].get_texture("error"),
|
||||||
|
Vec2(world[FightBox].p1[0], world[FightBox].p2[1] - 143),
|
||||||
|
3,
|
||||||
|
),
|
||||||
|
Spike(1),
|
||||||
|
Animation(
|
||||||
|
"spike/spike_down_coming",
|
||||||
|
30,
|
||||||
|
True,
|
||||||
|
callback=lambda _world, entity: entity.set(
|
||||||
|
Animation("spike/spike_down", 30, True),
|
||||||
|
Hurt(20),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
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(5)
|
||||||
|
|
||||||
|
for spike in world.query(Spike):
|
||||||
|
match spike.get(Spike):
|
||||||
|
case Spike.UP:
|
||||||
|
name = "up"
|
||||||
|
case Spike.DOWN:
|
||||||
|
name = "down"
|
||||||
|
case Spike.LEFT:
|
||||||
|
name = "left"
|
||||||
|
case Spike.RIGHT:
|
||||||
|
name = "right"
|
||||||
|
spike.set(
|
||||||
|
Animation(
|
||||||
|
"spike/spike_" + name + "_leaving",
|
||||||
|
30,
|
||||||
|
callback=lambda world, entity: entity.destroy(),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class RainProjectiles(Vec2):
|
class RainProjectiles(Vec2):
|
||||||
"""
|
"""
|
||||||
|
@ -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()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue