DX: textos a taula configurable, sentence case i tecla Q per sortir partida
This commit is contained in:
+46
-12
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user