From cd319a3bec32ccbe56dad98a7777bae43c74b141 Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Fri, 15 May 2026 13:52:26 +0200 Subject: [PATCH] DX: textos a taula configurable, sentence case i tecla Q per sortir partida --- config.lua | 18 ++++++++++++++ pepe_runner_dx.lua | 58 ++++++++++++++++++++++++++++++++++++---------- 2 files changed, 64 insertions(+), 12 deletions(-) diff --git a/config.lua b/config.lua index d0b0795..b7d3350 100644 --- a/config.lua +++ b/config.lua @@ -60,3 +60,21 @@ skin = "native" -- keys.right = KEY_RIGHT -- keys.dig_left = KEY_Z -- keys.dig_right = KEY_X +-- keys.quit = KEY_Q -- abandona la partida → game over + +-- ==================================================================== +-- TEXTOS DEL JOC +-- ==================================================================== +-- Tots els missatges que veu el jugador. Pots editar per a corregir +-- ortografia o traduir a una altra variant sense haver de tocar el .lua. +-- (Convencio: Inicial Majuscula, resta minuscula.) + +-- textos.title_press_play = "Prem l'espai per a jugar" +-- textos.game_over = "Fi de joc" +-- textos.new_record = "Nou record !" +-- textos.score_label = "Punts" +-- textos.level_label = "Nivell" +-- textos.lives_label = "Vides" +-- textos.record_label = "Record" +-- textos.name_label = "Nom:" +-- textos.name_help = "(A-Z)" diff --git a/pepe_runner_dx.lua b/pepe_runner_dx.lua index b62e576..dff5cd1 100644 --- a/pepe_runner_dx.lua +++ b/pepe_runner_dx.lua @@ -49,6 +49,8 @@ SKINS = { glif = SKINS.custom -- s'actualitza a init() segons la config -- Tecles del joc — sobreescriuibles per config.lua. +-- Nota: KEY_ESCAPE no es pot usar perque el interpret ascii la captura +-- per a la seva consola de debug abans que Lua la veja. keys = { up = KEY_UP, down = KEY_DOWN, @@ -56,6 +58,7 @@ keys = { right = KEY_RIGHT, dig_left = KEY_Z, dig_right = KEY_X, + quit = KEY_Q, -- abandona la partida → game over } -- Paleta — tots els colors son sobreescriuibles per config.lua. @@ -77,6 +80,20 @@ colors = { title = COLOR_LIGHT_RED, } +-- Textos del joc — sobreescriuibles per config.lua (taula `textos`). +-- Tots en sentence case (Inicial Majuscula, resta minuscula). +textos = { + title_press_play = "Prem l'espai per a jugar", + game_over = "Fi de joc", + new_record = "Nou record !", + score_label = "Punts", -- HUD i pantalla de nou record + level_label = "Nivell", + lives_label = "Vides", + record_label = "Record", + name_label = "Nom:", + name_help = "(A-Z)", +} + -- Estats (de TIPOS.PAS — son bitflags per a SelectEstat dels enemics) NORMAL = 0 PUJAR = 0x01 @@ -395,10 +412,11 @@ function update_title() neteja_fons() pintar_mapa(1) -- desplacem +1 col per a centrar el logo de map 0 - -- Missatge parpadejant ("Prem l'espai per a jugar") + -- Missatge parpadejant (textos.title_press_play) if flr(cnt() / 30) % 2 == 0 then color(COLOR_WHITE, colors.bg) - print("PREM L'ESPAI PER A JUGAR", 8, 22) + local t = textos.title_press_play + print(t, flr((40 - strlen(t)) / 2), 22) end pintar_hud() @@ -413,7 +431,8 @@ function update_gameover() pintar_pepe() color(colors.title, colors.bg) - print("F I D E J O C", 11, 12) + local g = textos.game_over + print(g, flr((40 - strlen(g)) / 2), 12) pintar_hud() @@ -435,12 +454,15 @@ end function update_entername() neteja_fons() color(colors.title, colors.bg) - print("NOU RECORD !", 14, 10) + local t = textos.new_record + print(t, flr((40 - strlen(t)) / 2), 10) color(colors.diners, colors.bg) - print("PUNTS "..string.format("%03d", hi_score), 15, 12) + local s = textos.score_label.." "..string.format("%03d", hi_score) + print(s, flr((40 - strlen(s)) / 2), 12) color(COLOR_WHITE, colors.bg) - print("NOM: "..nom_hi_score, 16, 15) - print("(A-Z)", 17, 17) + local n = textos.name_label.." "..nom_hi_score + print(n, flr((40 - strlen(n)) / 2), 15) + print(textos.name_help, flr((40 - strlen(textos.name_help)) / 2), 17) pintar_hud() @@ -460,6 +482,13 @@ end -- ----- PLAYING ----- function update_playing() + -- Abandonar partida → flux de game over (como en el RUNNER.PAS amb ESC) + if btnp(keys.quit) then + sfx_gameover() + set_estat(ESTAT_GAMEOVER) + return + end + -- Cavar es immediat (un sol forat per pulsacio) if pepe.estat == NORMAL then if btnp(keys.dig_left) and pot_cavar(-1) then foradar(pepe.x-1, pepe.y+1); sfx_dig() end @@ -714,10 +743,11 @@ function pintar_hud() end -- Text dins del marc - print("NIVELL "..string.format("%02d", level), 3, 26) - print("PUNTS "..string.format("%03d", score), 16, 26) - print("VIDES "..tostr(pepe.vides), 29, 26) - print("RECORD "..string.format("%03d", hi_score).." "..nom_hi_score, 13, 28) + print(textos.level_label.." "..string.format("%02d", level), 3, 26) + print(textos.score_label.." "..string.format("%03d", score), 16, 26) + print(textos.lives_label.." "..tostr(pepe.vides), 29, 26) + local r = textos.record_label.." "..string.format("%03d", hi_score).." "..nom_hi_score + print(r, flr((40 - strlen(r)) / 2), 28) end -- Carrega config.lua si existeix. Si falta o te errors, queden els defaults. @@ -725,9 +755,10 @@ end -- camp a camp, hi haura claus que falten. Fem un merge amb les defaults -- guardades per a que no quede res a nil. function carregar_config() - local saved_colors, saved_keys = {}, {} + local saved_colors, saved_keys, saved_textos = {}, {}, {} for k, v in pairs(colors) do saved_colors[k] = v end for k, v in pairs(keys) do saved_keys[k] = v end + for k, v in pairs(textos) do saved_textos[k] = v end pcall(dofile, "config.lua") for k, v in pairs(saved_colors) do if colors[k] == nil then colors[k] = v end @@ -735,6 +766,9 @@ function carregar_config() for k, v in pairs(saved_keys) do if keys[k] == nil then keys[k] = v end end + for k, v in pairs(saved_textos) do + if textos[k] == nil then textos[k] = v end + end end function init()