Assets pour Tricheur #48
BIN
assets/krita/tricheur_arrow.kra
Normal file
BIN
assets/krita/tricheur_background.kra
Normal file
BIN
assets/krita/tricheur_button.kra
Normal file
BIN
assets/textures/tricheur/arrow.png
Normal file
After Width: | Height: | Size: 6 KiB |
BIN
assets/textures/tricheur/arrow_hover.png
Normal file
After Width: | Height: | Size: 6.6 KiB |
BIN
assets/textures/tricheur/background.png
Normal file
After Width: | Height: | Size: 210 KiB |
BIN
assets/textures/tricheur/play_again.png
Normal file
After Width: | Height: | Size: 21 KiB |
BIN
assets/textures/tricheur/play_again_hover.png
Normal file
After Width: | Height: | Size: 22 KiB |
BIN
assets/textures/tricheur/valider.png
Normal file
After Width: | Height: | Size: 20 KiB |
BIN
assets/textures/tricheur/valider_hover.png
Normal file
After Width: | Height: | Size: 21 KiB |
|
@ -5,11 +5,15 @@ Definit un plugin qui crée un texte avec les touches frappées
|
||||||
from engine import Keyboard, Scene, Sound, Text, World
|
from engine import Keyboard, Scene, Sound, Text, World
|
||||||
|
|
||||||
|
|
||||||
class Typing(str):
|
class Typing:
|
||||||
"""
|
"""
|
||||||
Marque une entité comme un texte qui s'ecrit en fonction du clavier
|
Marque une entité comme un texte qui s'ecrit en fonction du clavier
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
def __init__(self, accepted_chars: str, max_chars: int = 10) -> None:
|
||||||
|
self.accepted_chars = accepted_chars
|
||||||
|
self.max_chars = max_chars
|
||||||
|
|
||||||
|
|
||||||
def __update(world: World):
|
def __update(world: World):
|
||||||
"""
|
"""
|
||||||
|
@ -24,7 +28,10 @@ def __update(world: World):
|
||||||
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].accepted_chars
|
||||||
|
and len(text) < entity[Typing].max_chars
|
||||||
|
):
|
||||||
world.create_entity(Sound("click"))
|
world.create_entity(Sound("click"))
|
||||||
text += key
|
text += key
|
||||||
entity[Text] = Text(text)
|
entity[Text] = Text(text)
|
||||||
|
|
|
@ -83,11 +83,12 @@ def __initialize_world(world: World):
|
||||||
Position(Display.WIDTH / 2, 750),
|
Position(Display.WIDTH / 2, 750),
|
||||||
Order(2),
|
Order(2),
|
||||||
Centered(),
|
Centered(),
|
||||||
typing.Typing("1234567890"),
|
typing.Typing("1234567890", 2),
|
||||||
Text(""),
|
Text(""),
|
||||||
COLOR_TEXT,
|
COLOR_TEXT,
|
||||||
TextSize(150),
|
TextSize(150),
|
||||||
)
|
)
|
||||||
|
# on clamp avec la lib
|
||||||
|
|
||||||
# Text qui dit si ton nombre et trop grand ou trop petit
|
# Text qui dit si ton nombre et trop grand ou trop petit
|
||||||
world.create_entity(
|
world.create_entity(
|
||||||
|
|
|
@ -84,7 +84,7 @@ def __initialize_world(world: World):
|
||||||
Position(Display.WIDTH / 2, 750),
|
Position(Display.WIDTH / 2, 750),
|
||||||
Order(2),
|
Order(2),
|
||||||
Centered(),
|
Centered(),
|
||||||
typing.Typing("1234567890"),
|
typing.Typing("1234567890", 2),
|
||||||
Text(""),
|
Text(""),
|
||||||
COLOR_TEXT,
|
COLOR_TEXT,
|
||||||
TextSize(150),
|
TextSize(150),
|
||||||
|
|