Ajout de sons

This commit is contained in:
Tipragot 2023-11-05 21:20:02 +01:00
parent 5d9cbdc1b6
commit 7149019109
9 changed files with 14 additions and 2 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -216,7 +216,7 @@ def loading_scene(target: Scene, name: str, clear_cache: bool = True):
order=1000000001, order=1000000001,
area=(0, 0, 0, render.HEIGHT), area=(0, 0, 0, render.HEIGHT),
), ),
Sound(assets.waiting_sound, loop=True, fade_ms=10000), Sound(assets.waiting_sound, loop=True),
) )
@staticmethod @staticmethod

View file

@ -19,6 +19,10 @@ from plugins.assets import Assets
from plugins.coroutine import condition, wait, Coroutine from plugins.coroutine import condition, wait, Coroutine
from plugins.sound import Sound from plugins.sound import Sound
from plugins.timing import Delta, TimedEvent from plugins.timing import Delta, TimedEvent
from plugins.multisound import MultiSound
SHOOT = MultiSound("shoot/1", "shoot/2", "shoot/3", volume=0.1)
class Velocity(int): class Velocity(int):
@ -144,6 +148,8 @@ def __initialize_world(world: World):
""" """
TODO TODO
""" """
world.new_entity().set(Sound(world[Assets].get_sound("music"), True, 0.5))
world.set( world.set(
ShieldPos(Vec2(render.WIDTH / 2, 750)), ShieldPos(Vec2(render.WIDTH / 2, 750)),
FightBox(), FightBox(),
@ -317,6 +323,7 @@ def __check_hurt(world: World):
) )
else: else:
entity.destroy() entity.destroy()
world.new_entity().set(Sound(world[Assets].get_sound("hit")))
world.new_entity().set(Coroutine(__set_hurtable_hurt(world))) world.new_entity().set(Coroutine(__set_hurtable_hurt(world)))
world.set(Hurtable.FALSE) world.set(Hurtable.FALSE)
__update_life_bar(world) __update_life_bar(world)
@ -335,6 +342,8 @@ def __defeat(world: World):
entity.remove(smooth.Target) entity.remove(smooth.Target)
for entity in world.query(Animation): for entity in world.query(Animation):
entity.remove(Animation) entity.remove(Animation)
for entity in world.query(Sound):
entity.remove(Sound)
for entity in world.query(Player): for entity in world.query(Player):
entity.set( entity.set(
@ -347,7 +356,7 @@ def __defeat(world: World):
world.new_entity().set( world.new_entity().set(
Sprite(world[Assets].error_texture, order=20), Sprite(world[Assets].error_texture, order=20),
Animation("animation_bg_mort", 24), Animation("animation_bg_mort", 24),
Sound(world[Assets].get_sound("game_over"), True, 0.5, 10000), Sound(world[Assets].get_sound("game_over"), True, 1),
) )
elif len(world[Held]) > 0 and len(world.query(Animation)) == 0: elif len(world[Held]) > 0 and len(world.query(Animation)) == 0:
world[CurrentScene] = __new_game_scene() world[CurrentScene] = __new_game_scene()
@ -414,6 +423,7 @@ def __create_zone_attack(world: World, number: int = 2):
) )
yield animation.wait() yield animation.wait()
entity.destroy() entity.destroy()
world.new_entity().set(Sound(world[Assets].get_sound("zone")))
for i in range(10): for i in range(10):
projectile = world.new_entity() projectile = world.new_entity()
@ -624,6 +634,7 @@ def __rainning_projectiles(world: World, number: int = 20):
yield animation.wait() yield animation.wait()
yield wait(0.2) yield wait(0.2)
entity.set(smooth.Target(Vec2(entity[Sprite].position.x, 1121))) entity.set(smooth.Target(Vec2(entity[Sprite].position.x, 1121)))
world.new_entity().set(SHOOT)
for entity in world.query(RainProjectiles, Sprite): for entity in world.query(RainProjectiles, Sprite):
if entity[Sprite].position.y > 1080: if entity[Sprite].position.y > 1080:
@ -650,6 +661,7 @@ def __horizontal_projectile(world: World, left: bool, number: int = 10):
) )
yield animation.wait() yield animation.wait()
yield wait(1) yield wait(1)
world.new_entity().set(SHOOT)
entity.set( entity.set(
smooth.Target(Vec2(1500 if left else -81, entity[Sprite].position.y)) smooth.Target(Vec2(1500 if left else -81, entity[Sprite].position.y))
) )