Add typing sounds

This commit is contained in:
Tipragot 2023-11-03 11:11:42 +01:00
parent c47cae3967
commit 96bb74d246

View file

@ -5,6 +5,7 @@ Definit un plugin qui crée un texte avec les touches frappées
from engine import Scene, World from engine import Scene, World
from plugins.inputs import Pressed from plugins.inputs import Pressed
from plugins.text import Text from plugins.text import Text
from scenes import CLICK_SOUND
class Writing: class Writing:
@ -31,6 +32,7 @@ def __update(world: World):
for key in pressed: for key in pressed:
if key == "backspace": if key == "backspace":
text.text = text.text[:-1] text.text = text.text[:-1]
world.new_entity().set(CLICK_SOUND)
if key.startswith("["): # pavé numerique if key.startswith("["): # pavé numerique
key = key[1] key = key[1]
if key in writing.accepted_chars and ( if key in writing.accepted_chars and (
@ -40,6 +42,7 @@ def __update(world: World):
text.text = key text.text = key
else: else:
text.text += key text.text += key
world.new_entity().set(CLICK_SOUND)
if text.text == "": if text.text == "":
text.text = writing.base_text text.text = writing.base_text