Ajoute d'un systeme de son #34

Merged
CoCo_Sol merged 12 commits from sound into main 2023-10-29 15:11:50 +00:00
3 changed files with 12 additions and 12 deletions
Showing only changes of commit fabb474e5c - Show all commits

BIN
assets/sounds/click.wav Normal file

Binary file not shown.

View file

@ -10,6 +10,7 @@ from scenes import menu
start_game(
{
"menu": menu.SCENE,
"classique": menu.SCENE,
},
"menu",
title="Guess The Number",

View file

@ -6,9 +6,9 @@ from engine import (
Centered,
Clickable,
Display,
Entity,
Game,
HoveredTexture,
Keyboard,
Order,
Position,
Scene,
@ -28,10 +28,18 @@ def __create_button(world: World, i: int, name: str):
Centered(),
Texture(f"menu/button_{name}.png"),
HoveredTexture(f"menu/button_{name}_hover.png"),
Clickable(lambda world, _: world[Game].change_scene(name)),
Clickable(lambda world, entity: on_click_butons(world, entity, name)),
)
def on_click_butons(world: World, entity: Entity, name: str):
"""
Fonction qui s'execute quand on clique sur un bouton.
"""
entity[Sound] = Sound("click.wav")
world[Game].change_scene(name)
def __initialize_world(world: World):
"""
Initialise le monde du menu.
@ -42,17 +50,8 @@ def __initialize_world(world: World):
__create_button(world, i, name)
def get_pressed(world: World):
"""
Renvoie les touches appuyées.
"""
if world[Keyboard].is_key_pressed("a"):
for entity in world.query(Sound):
del entity[Sound]
SCENE = Scene(
[__initialize_world],
[get_pressed],
[],
[],
)