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
|
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)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue