From f26964e6974769c63e24f3fc021488d352ce9e1f Mon Sep 17 00:00:00 2001 From: markojozsef Date: Sat, 17 Oct 2026 14:53:30 +0200 Subject: [PATCH] =?UTF-8?q?Akci=C3=B3=20panel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/gamestates/battle.py | 11 +++++++++-- src/text.py | 9 ++++++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/gamestates/battle.py b/src/gamestates/battle.py index 3364c19..4902621 100644 --- a/src/gamestates/battle.py +++ b/src/gamestates/battle.py @@ -31,7 +31,9 @@ cur_action = None action_timer = 0 menu_text = TextRenderer(6, 76, 210) -action_text = TextRenderer(110, 215, 210) +action_text = TextRenderer(128, 204, None, True) +action_panel = renderers.NineSlicesPanel(73,187,110,40) +show_action_panel = False menu_open = 0 menu_queue = [] @@ -243,7 +245,7 @@ def menu_action(data): # !!! CHATGPT VÉGE !!! def update(game, dt): - global menu_open, cur_action, action_timer + global menu_open, cur_action, action_timer, show_action_panel for e in enemies: if e.ko or e.stone: @@ -268,11 +270,13 @@ def update(game, dt): action = action_queue.pop(0) print(f"Executing: {action}") cur_action = action + show_action_panel = True action_timer = 0 if cur_action != None: if cur_action.animation(cur_action, action_text, action_timer, dt): cur_action = None + show_action_panel = False else: action_timer += dt @@ -341,5 +345,8 @@ def draw(game): m.render() menu_text.render() + + if show_action_panel: + action_panel.render() action_text.render() diff --git a/src/text.py b/src/text.py index 6a69455..b0cd1e1 100644 --- a/src/text.py +++ b/src/text.py @@ -12,11 +12,12 @@ class Character: self.display = display # Egy függvény amely akkor fut le amikor a speciális karaktert megjelenítik class TextRenderer: - def __init__(self, x, y, width=None): + def __init__(self, x, y, width=None, center=False): self.sprites = [] self.base_x = x self.base_y = y self.width = width + self.center = center self.text = "" self.textptr = 0 self.x = x @@ -56,7 +57,8 @@ class TextRenderer: self.y + char.y_offset, char.width, 12 - ) + ), + char.width ]) self.x += char.width @@ -78,10 +80,11 @@ class TextRenderer: pass def render(self): + offset = -(sum(s[2] for s in self.sprites) // 2) if self.center else 0 for s in self.sprites: arcade.draw_texture_rect( s[0], - s[1], + s[1].move(offset, 0), pixelated=True )