diff --git a/src/plugins/text.py b/src/plugins/text.py index 9e37e6c..92e602f 100644 --- a/src/plugins/text.py +++ b/src/plugins/text.py @@ -23,12 +23,14 @@ class Text: size: int = 50, color: pygame.Color = pygame.Color(255, 255, 255), position: Vec2 = Vec2(0), + order: float = -1.0, origin: Vec2 = Vec2(0), ): self.text = text self.size = size self.color = color self.position = position + self.order = order self.origin = origin @@ -47,6 +49,7 @@ def __render_texts(world: World): else: entity[Sprite] = Sprite(texture) entity[Sprite].position = text.position + entity[Sprite].order = text.order entity[Sprite].origin = text.origin diff --git a/src/plugins/writing.py b/src/plugins/writing.py index ea8debc..ba4551d 100644 --- a/src/plugins/writing.py +++ b/src/plugins/writing.py @@ -25,17 +25,19 @@ def __update(world: World): for entity in world.query(Writing, Text): text = entity[Text] for key in pressed: - if text.text == "...": - text.text = "" if key == "backspace": text.text = text.text[:-1] + if text.text == "": + text.text = "..." if key.startswith("["): # pavé numerique key = key[1] - if ( - key in entity[Writing].accepted_chars - and len(text.text) < entity[Writing].max_chars + if key in entity[Writing].accepted_chars and ( + text.text == "..." or len(text.text) < entity[Writing].max_chars ): - text.text += key + if text.text == "...": + text.text = key + else: + text.text += key PLUGIN = Scene( diff --git a/src/scenes/basic_game.py b/src/scenes/basic_game.py index f24b2c3..52f7fc3 100644 --- a/src/scenes/basic_game.py +++ b/src/scenes/basic_game.py @@ -122,6 +122,7 @@ def __initialize_world(world: World): 150, text_color, Vec2(render.WIDTH / 2, 450), + 1.0, Vec2(0.5), ), Response(), @@ -133,6 +134,7 @@ def __initialize_world(world: World): 150, text_color, Vec2(render.WIDTH / 2, 650), + 1.0, Vec2(0.5), ), Writing("0123456789", 2), diff --git a/src/scenes/menu.py b/src/scenes/menu.py index 3aafcae..b57c570 100644 --- a/src/scenes/menu.py +++ b/src/scenes/menu.py @@ -24,6 +24,7 @@ def __create_button(world: World, assets: Assets, i: int, name: str): Sprite( assets.error_texture, Vec2(render.WIDTH / 2, 450 + 150 * i), + 1, origin=Vec2(0.5), ), HoveredTexture(