diff --git a/maps/0.map b/maps/0.map new file mode 100644 index 0000000..a623481 Binary files /dev/null and b/maps/0.map differ diff --git a/maps/1.map b/maps/1.map new file mode 100644 index 0000000..0f2d1b1 Binary files /dev/null and b/maps/1.map differ diff --git a/maps/10.map b/maps/10.map new file mode 100644 index 0000000..79c1549 Binary files /dev/null and b/maps/10.map differ diff --git a/maps/2.map b/maps/2.map new file mode 100644 index 0000000..5070d9b Binary files /dev/null and b/maps/2.map differ diff --git a/maps/3.map b/maps/3.map new file mode 100644 index 0000000..06d5ec0 Binary files /dev/null and b/maps/3.map differ diff --git a/maps/4.map b/maps/4.map new file mode 100644 index 0000000..3e44628 Binary files /dev/null and b/maps/4.map differ diff --git a/maps/5.map b/maps/5.map new file mode 100644 index 0000000..8301f2c Binary files /dev/null and b/maps/5.map differ diff --git a/maps/6.map b/maps/6.map new file mode 100644 index 0000000..b4faf58 Binary files /dev/null and b/maps/6.map differ diff --git a/maps/7.map b/maps/7.map new file mode 100644 index 0000000..664bb39 Binary files /dev/null and b/maps/7.map differ diff --git a/maps/8.map b/maps/8.map new file mode 100644 index 0000000..7893abc Binary files /dev/null and b/maps/8.map differ diff --git a/maps/9.map b/maps/9.map new file mode 100644 index 0000000..b287f3c Binary files /dev/null and b/maps/9.map differ diff --git a/pepe_runner.lua b/pepe_runner.lua new file mode 100644 index 0000000..fbefe8c --- /dev/null +++ b/pepe_runner.lua @@ -0,0 +1,106 @@ +-- Pepe Runner — port a ascii/Lua del joc original en Turbo Pascal (JailDesigner, 2000) +-- Fase 1: render estatic d'un mapa + +-- Codis CP437 dels sprites del joc original (de TIPOS.PAS) +BUIT = 0 +DINERS = 36 -- $ +PEDRA = 219 -- bloc solid +ESCALA = 205 -- ═ (linia doble horitzontal, formant graons d'escala) +CORDA = 196 -- ─ (linia simple horitzontal) +BLOC1 = 176 -- ░ +BLOC2 = 177 -- ▒ +BLOC3 = 178 -- ▓ +PEPE_C = 2 -- sprite del Pepe +MALO_C = 88 -- 'X' enemics + +-- Colors (de TIPOS.PAS, paleta CGA — coincideix amb la d'ascii) +COL_PEDRA = COLOR_BROWN -- 6 +COL_DINERS = COLOR_YELLOW -- 14 +COL_ESCALA = COLOR_LIGHT_GRAY -- 7 +COL_CORDA = COLOR_LIGHT_GRAY -- 7 +COL_BUIT = COLOR_BLACK -- 0 + +-- Mida del mapa (del joc original) +MAP_W = 40 +MAP_H = 25 + +-- Estat +mapa = {} -- mapa[x][y] = { tipo=, color=, temps= } +level = 1 + +function definir_glifs() + -- Cel·la buida (sobreescrivim el glif 0 del ROM, que no es buit) + setchar(BUIT, 0,0,0,0,0,0,0,0) + + -- Pedra (█) — bloc solid + setchar(PEDRA, 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF) + + -- Diners ($) — signe dolar classic + setchar(DINERS, 0x18,0x3E,0x60,0x3C,0x06,0x7C,0x18,0x00) + + -- Escala (═) — doble linia horitzontal + setchar(ESCALA, 0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00) + + -- Corda (─) — linia horitzontal simple + setchar(CORDA, 0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00) + + -- Blocs degradats (per al fade dels forats) + setchar(BLOC1, 0x44,0x11,0x44,0x11,0x44,0x11,0x44,0x11) -- ░ light + setchar(BLOC2, 0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55) -- ▒ medium + setchar(BLOC3, 0xBB,0xEE,0xBB,0xEE,0xBB,0xEE,0xBB,0xEE) -- ▓ dark + + -- Pepe (cara feliç tipus CP437 char 2 ☻) + setchar(PEPE_C, 0x7E,0x81,0xA5,0x81,0xBD,0x99,0x81,0x7E) + + -- Enemic — una 'X' marcada + setchar(MALO_C, 0x00,0xC3,0x66,0x3C,0x18,0x3C,0x66,0xC3) +end + +-- Retorna el color associat a un tipus de cel·la +function color_de(tipo) + if tipo == PEDRA then return COL_PEDRA end + if tipo == DINERS then return COL_DINERS end + if tipo == ESCALA then return COL_ESCALA end + if tipo == CORDA then return COL_CORDA end + return COL_BUIT +end + +-- Carrega un mapa des d'un fitxer .map (1000 bytes, column-major: byte[x*25+y]) +-- Estrategia: filein() a l'adreca 0 (sobreescriu char_screen), llegim amb peek() +-- a una taula Lua, i despres fem cls() per netejar la pantalla. +function carregar_mapa(num) + filein("maps/"..tostr(num)..".map", 0, MAP_W*MAP_H) + for x = 0, MAP_W-1 do + mapa[x] = {} + for y = 0, MAP_H-1 do + local tipo = peek(x*MAP_H + y) + mapa[x][y] = { tipo=tipo, color=color_de(tipo), temps=-1 } + end + end +end + +function pintar_mapa() + for x = 0, MAP_W-1 do + for y = 0, MAP_H-1 do + local c = mapa[x][y] + if c.tipo ~= BUIT then + color(c.color, COL_BUIT) + print(chr(c.tipo), x, y) + end + end + end +end + +function init() + mode(1) -- 40x30 chars, color per cel·la + border(COLOR_BLUE) + color(COLOR_LIGHT_GRAY, COLOR_BLACK) + definir_glifs() + carregar_mapa(level) + cls() -- neteja despres del filein (que ha escrit a char_screen) + pintar_mapa() +end + +function update() + -- Fase 1: nomes render estatic, res que actualitzar encara +end