Les sons du jeu classique #43

Merged
tipragot merged 7 commits from sound-classique into main 2023-10-30 00:21:25 +00:00
2 changed files with 3 additions and 1 deletions
Showing only changes of commit 31ecb98485 - Show all commits

BIN
assets/sounds/backspace.wav Normal file

Binary file not shown.

View file

@ -2,7 +2,7 @@
Definit un plugin qui crée un texte avec les touches frappées Definit un plugin qui crée un texte avec les touches frappées
""" """
from engine import Keyboard, Scene, Text, World from engine import Keyboard, Scene, Sound, Text, World
class Typing(str): class Typing(str):
@ -20,10 +20,12 @@ def __update(world: World):
text = entity[Text] text = entity[Text]
for key in keyboard.pressed: for key in keyboard.pressed:
if key == "backspace": if key == "backspace":
world.create_entity(Sound("backspace.wav"))
text = text[:-1] text = text[:-1]
if key.startswith("["): # pavé numerique if key.startswith("["): # pavé numerique
key = key[1] key = key[1]
if key in entity[Typing]: if key in entity[Typing]:
world.create_entity(Sound("click.wav"))
text += key text += key
entity[Text] = Text(text) entity[Text] = Text(text)