Les sons du jeu classique #43
BIN
assets/sounds/backspace.wav
Normal file
BIN
assets/sounds/backspace.wav
Normal file
Binary file not shown.
|
@ -2,7 +2,7 @@
|
|||
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):
|
||||
|
@ -20,10 +20,12 @@ def __update(world: World):
|
|||
text = entity[Text]
|
||||
for key in keyboard.pressed:
|
||||
if key == "backspace":
|
||||
world.create_entity(Sound("backspace.wav"))
|
||||
text = text[:-1]
|
||||
if key.startswith("["): # pavé numerique
|
||||
key = key[1]
|
||||
if key in entity[Typing]:
|
||||
world.create_entity(Sound("click.wav"))
|
||||
text += key
|
||||
entity[Text] = Text(text)
|
||||
|
||||
|
|
Loading…
Reference in a new issue