commit f218255f145cc95a257eff77bc95ea43e8b1cb7b Author: JailGamer Date: Wed Mar 18 13:27:46 2026 +0100 Arranquem! diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8c1ac73 --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +.DS_STORE +release/* +*.exe +*.dll +mini +mini_debug +data-old diff --git a/data/arcade_config.lua b/data/arcade_config.lua new file mode 100644 index 0000000..9a08d73 --- /dev/null +++ b/data/arcade_config.lua @@ -0,0 +1,32 @@ +local arcade_config = { + org_resolucion = { width = 128, height = 96 }, + resolucion = { width = 256, height = 192 }, + surface = { width = 256, height = 192 }, + logo_sf = { width = 144, height = 20 }, + sprite_size = { w = 32, h = 32 }, + escala = 1.0, + org2arc_escala = 2.0, + tiles_offset = 128, + tiles_per_row = 16, + tiles_per_row_base2 = 4, + tiles_width = 16, + tiles_height = 16, + character_per_row = 8, + character_per_row_base2 = 3, + character_width = 32, + character_height = 32, + fullscreen = false +} + +-- Proteger contra creación/modificación accidental de campos no declarados +-- setmetatable(config, { +-- __newindex = function(t, k, v) +-- if rawget(t, k) == nil then +-- error("Intento de crear campo nuevo en config: "..tostring(k), 2) +-- else +-- rawset(t, k, v) +-- end +-- end +-- }) + +return arcade_config diff --git a/data/audio.lua b/data/audio.lua new file mode 100644 index 0000000..e639491 --- /dev/null +++ b/data/audio.lua @@ -0,0 +1,20 @@ +audio_main_song="mus_menu.ogg" +audio_song_batman="mus_batm.ogg" +audio_song_premiere="mus_prem.ogg" +audio_song_elalien="mus_alie.ogg" +audio_life_lost="mus_life.ogg" +audio_game_over="mus_over.ogg" +audio_final=audio_main_song + +audio_abad_jump="snd_ajmp.wav" +audio_abad_fall="snd_afal.wav" +audio_abad_hit="snd_ahit.wav" +audio_abad_shot="snd_asht.wav" +audio_abad_step={"snd_ast1.wav", "snd_ast2.wav", "snd_ast3.wav", "snd_ast2.wav"} +audio_switch="snd_swch.wav" +audio_hit="snd_hit.wav" +audio_low="snd_low.wav" +audio_text_abad="snd_txta.wav" +audio_text_premiere="snd_txtp.wav" +audio_text_elalien="snd_txte.wav" +audio_text_batman="snd_txtb.wav" diff --git a/data/fade.lua b/data/fade.lua new file mode 100644 index 0000000..277f9d6 --- /dev/null +++ b/data/fade.lua @@ -0,0 +1,99 @@ +fade = { + table={13,15,5,3,12,5,6,7,12,9,10,16,9,13,14}, + pal={}, + old_update=nil, + wait=0, + step=0, + outin=false, + + init = function() + for i=1,15 do + local r,g,b=pal.color(i) + fade.pal[i]={r,g,b} + end + end, + + getstep=function(num,steps) + if steps==0 or num==16 then return num end + for i=1,steps do + num=fade.table[num] + if num==16 then return num end + end + return num + end, + + fadeout = function() + --print("fading out") + fade.old_update=game_update + game_update=fade.update_fadeout + fade.wait=0 + fade.step=0 + end, + + fadeoutin = function() + --print("fading outin") + fade.old_update=game_update + game_update=fade.update_fadeout + fade.wait=0 + fade.step=0 + fade.outin=true + end, + + update_fadeout=function() + --print("out") + fade.wait=fade.wait+1 + if fade.wait==6 then + fade.wait=0 + for i=1,15 do + local v=fade.getstep(i,fade.step) + --print(v) + if v==16 then + pal.color(i,0,0,0) + else + pal.color(i,fade.pal[v][1],fade.pal[v][2],fade.pal[v][3]) + end + end + fade.step=fade.step+1 + if fade.step==7 then + game_update = fade.old_update + if fade.outin then + fade.outin=false; + fade.fadein() + end + end + end + end, + + fadein = function() + --print("fading in") + fade.old_update=game_update + game_update=fade.update_fadein + fade.wait=0 + fade.step=6 + for i=1,15 do pal.color(i,0,0,0) end + end, + + update_fadein=function() + --print("in") + fade.old_update() + + fade.wait=fade.wait+1 + if fade.wait==6 then + fade.wait=0 + for i=1,15 do + local v=fade.getstep(i,fade.step) + --print(v) + if v==16 then + pal.color(i,0,0,0) + else + pal.color(i,fade.pal[v][1],fade.pal[v][2],fade.pal[v][3]) + end + end + fade.step=fade.step-1 + if fade.step<0 then + game_update = fade.old_update + end + end + end + +} diff --git a/data/fps.lua b/data/fps.lua new file mode 100644 index 0000000..488b226 --- /dev/null +++ b/data/fps.lua @@ -0,0 +1,19 @@ +local last_time = os.clock() +local frame_count = 0 +local fps = 0 +local sample_interval = 1 -- segundos + +function frame() -- llama esto cada frame; recibe dt si tu motor lo proporciona + frame_count = frame_count + 1 + local now = os.clock() + local elapsed = now - last_time + if elapsed >= sample_interval then + fps = frame_count / elapsed + frame_count = 0 + last_time = now + end + return fps +end + +-- ejemplo de uso dentro de tu bucle: +-- local current_fps = frame() diff --git a/data/game.ini b/data/game.ini new file mode 100644 index 0000000..9337654 --- /dev/null +++ b/data/game.ini @@ -0,0 +1,5 @@ +title=Cacaus Arcade +config=cacaus_arcade +width=256 +height=192 +zoom=3 diff --git a/data/intro.lua b/data/intro.lua new file mode 100644 index 0000000..75b4a33 --- /dev/null +++ b/data/intro.lua @@ -0,0 +1,143 @@ +require "fps" + +require "fade" + + +-- require "game" +-- require "mapa" +-- require "scenes" + +local arcade_config = require("arcade_config") +o2aX = arcade_config.org2arc_escala + +intro_wait=40 +intro_step=0 + +function intro_init() + game_update = intro_intro + intro_wait=400 + surf.cls(16) + + surf.target(logo) + surf.cls(16) + draw.text("INTRO_INIT",0,0,15) + surf.target(0) + surf.source(logo) + draw.surf(0,0,36,5,56,70,arcade_config.logo_sf.width,arcade_config.logo_sf.height) + + -- surf.source(tiles) + -- fade.fadein() +end + +function intro_intro() + -- text("presenta",48,50,14) + + intro_wait=intro_wait-1 + if intro_wait==0 or key.press(key.ESCAPE) or key.press(keyShoot) or pad.press(btnShoot) or pad.press(btnPause) then + intro_wait=1 + -- game_update = intro_update + game_update = print_fps + fade.fadeoutin() + end + +end + +function draw_item_intro( name, flip ) + local cw = arcade_config.character_width + local ch = arcade_config.character_height + if ( name == "abad" ) then + draw.surf(0,0,cw,ch,44*o2aX,24*o2aX,cw,ch,flip) + elseif (name == "batman" ) then + draw.surf(0,48*o2aX,cw,ch,82*o2aX,24*o2aX,cw,ch,flip) + elseif (name == "cacaus" ) then + draw.surf(112*o2aX,88*o2aX,cw,ch/2,76*o2aX,32*o2aX,cw,ch/2,flip) + elseif (name == "marc" ) then + draw.rect(15*o2aX,3*o2aX,99*o2aX,51*o2aX,2) + elseif (name == "pas porta" ) then + draw.rectf(73*o2aX,24*o2aX,7*o2aX,16*o2aX,16) + end +end + +function draw_escenari () + surf.cls(16) + draw_item_intro("marc",false) + view.origin(16*o2aX,4*o2aX) + mapa_draw(10) + -- Borrar la porta del mapa + draw_item_intro("pas porta") +end + +function print_fps () + print("IN") + local current_fps = frame() + surf.cls(16) + surf.target(logo) + surf.cls(16) + draw.text(current_fps.."fps",0,0,15) + surf.target(0) + surf.source(logo) + draw.surf(0,0,36,5,56,70,arcade_config.logo_sf.width,arcade_config.logo_sf.height) +end + +function intro_update() + if key.press(key.ESCAPE) or pad.press(btnPause) then + game_init(true) + fade.fadeoutin() + elseif key.press(key.SPACE) then + intro_wait=1 + end + + + intro_wait=intro_wait-1 + if intro_wait==0 then + -- STEP 0 + if intro_step==0 then + draw_escenari() + draw_item_intro("abad", true) + view.origin(0,0) + intro_step=intro_step+1 + -- STEP 1 + elseif intro_step==1 then + start_scene(scenes.intro_01,58) + intro_step=intro_step+1 + -- STEP 2 + elseif intro_step==2 then + draw_escenari() + draw_item_intro("abad", false) + view.origin(0,0) + intro_step=intro_step+1 + -- STEP 3 + elseif intro_step==3 then + start_scene(scenes.intro_02,58) + intro_step=intro_step+1 + -- STEP 4 + elseif intro_step==4 then + draw_escenari() + draw_item_intro("abad", false) + draw_item_intro("cacaus", true) + draw_item_intro("batman", true) + view.origin(0,0) + intro_step=intro_step+1 + -- STEP 5 + elseif intro_step==5 then + start_scene(scenes.intro_03,58) + intro_step=intro_step+1 + -- STEP 6 + elseif intro_step==6 then + draw_escenari() + draw_item_intro("abad", false) + view.origin(0,0) + intro_step=intro_step+1 + -- STEP 7 + elseif intro_step==7 then + start_scene(scenes.intro_04,58) + intro_step=intro_step+1 + -- STEP 8 + elseif intro_step==8 then + music.play(audio_main_song) + game_init(true) + fade.fadeoutin() + end + intro_wait=50 + end +end \ No newline at end of file diff --git a/data/main.lua b/data/main.lua new file mode 100644 index 0000000..a0e4e8c --- /dev/null +++ b/data/main.lua @@ -0,0 +1,118 @@ +require "fade" +require "audio" +require "intro" + +local arcade_config = require("arcade_config") + +function mini.init() + tiles=surf.load("tiles.gif") + surf.source(tiles) + local paleta=pal.load("tiles.gif") + pal.set(paleta) + + logo=surf.new(arcade_config.logo_sf.width,arcade_config.logo_sf.height) + back=surf.new(arcade_config.surface.width,arcade_config.surface.height) + fade.init() + + textsf=surf.new(arcade_config.org_resolucion.width,arcade_config.org_resolucion.height) + + -- Càrrega dels audios + audio_text_abad = sound.load(audio_text_abad) + audio_text_premiere = sound.load(audio_text_premiere) + audio_text_elalien = sound.load(audio_text_elalien) + audio_text_batman = sound.load(audio_text_batman) + audio_abad_jump = sound.load(audio_abad_jump) + audio_abad_fall = sound.load(audio_abad_fall) + audio_abad_hit = sound.load(audio_abad_hit) + audio_abad_shot = sound.load(audio_abad_shot) + audio_abad_step[1] = sound.load(audio_abad_step[1]) + audio_abad_step[2] = sound.load(audio_abad_step[2]) + audio_abad_step[3] = sound.load(audio_abad_step[3]) + audio_abad_step[4] = audio_abad_step[2] + audio_switch = sound.load(audio_switch) + audio_hit = sound.load(audio_hit) + audio_low = sound.load(audio_low) + + -- Configuració dels input + keyUp = tonumber(config.key("keyup")) or key.UP + keyDown = tonumber(config.key("keydown")) or key.DOWN + keyLeft = tonumber(config.key("keyleft")) or key.LEFT + keyRight = tonumber(config.key("keyright")) or key.RIGHT + keyJump = tonumber(config.key("keyjump")) or key.UP + keyShoot = tonumber(config.key("keyshoot")) or key.SPACE + + btnUp = tonumber(config.key("btnup")) or pad.UP + btnDown = tonumber(config.key("btndown")) or pad.DOWN + btnLeft = tonumber(config.key("btnleft")) or pad.LEFT + btnRight = tonumber(config.key("btnright")) or pad.RIGHT + btnJump = tonumber(config.key("btnjump")) or pad.B + btnShoot = tonumber(config.key("btnshoot")) or pad.A + btnCycle1 = tonumber(config.key("btncycle1")) or pad.RIGHTSHOULDER + btnCycle2 = tonumber(config.key("btncycle2")) or pad.LEFTSHOULDER + btnPause = tonumber(config.key("btnpause")) or pad.START + + -- game_init() + intro_init() + -- final_init() +end + +function mini.update() + if key.press(key.F1) then + win.zoom(win.zoom()-1) + elseif key.press(key.F2) then + win.zoom(win.zoom()+1) + elseif key.press(key.F3) then + local fs = win.fullscreen() + win.fullscreen(not fs) + win.cursor(fs) + end + + if (game_update) then game_update() end + +end + +function arc_text(str, x, y, col) + local curr_surf_tgt = surf.target() + local curr_surf_src = surf.source() + local sw = arcade_config.org_resolucion.width + local sh = arcade_config.org_resolucion.height + local dw = arcade_config.resolucion.width + local dh = arcade_config.resolucion.height + surf.target(textsf) + surf.cls(0) + draw.text(str,0,0,col) + -- print("arc_ "..str) + surf.source(textsf) + surf.target(curr_surf_tgt) + draw.surf(0,0,sw,sh,x,y,dw,dh) + surf.source(curr_surf_src) +end + +function arc_textB(str, x, y, col) + local ox, oy = view.origin() + local curr_surf_tgt = surf.target() + local curr_surf_src = surf.source() + local sw = arcade_config.org_resolucion.width + local sh = arcade_config.org_resolucion.height + local dw = arcade_config.resolucion.width + local dh = arcade_config.resolucion.height + surf.target(textsf) + view.origin(0,0) + surf.cls(0) + draw.text(str,0,0,16) + draw.text(str,1,0,16) + draw.text(str,2,0,16) + draw.text(str,0,1,16) + draw.text(str,2,1,16) + draw.text(str,0,2,16) + draw.text(str,1,2,16) + draw.text(str,2,2,16) + + draw.text(str,1,1,col) + -- print("arc_B "..str) + surf.source(textsf) + surf.target(curr_surf_tgt) + view.origin(ox,oy) + draw.surf(0,0,sw,sh,x,y,dw,dh) + surf.source(curr_surf_src) +end \ No newline at end of file diff --git a/data/mus_alie.ogg b/data/mus_alie.ogg new file mode 100644 index 0000000..64c7fc6 Binary files /dev/null and b/data/mus_alie.ogg differ diff --git a/data/mus_batm.ogg b/data/mus_batm.ogg new file mode 100644 index 0000000..2bbc50b Binary files /dev/null and b/data/mus_batm.ogg differ diff --git a/data/mus_life.ogg b/data/mus_life.ogg new file mode 100644 index 0000000..64dad73 Binary files /dev/null and b/data/mus_life.ogg differ diff --git a/data/mus_menu.ogg b/data/mus_menu.ogg new file mode 100644 index 0000000..d9782ab Binary files /dev/null and b/data/mus_menu.ogg differ diff --git a/data/mus_over.ogg b/data/mus_over.ogg new file mode 100644 index 0000000..8974871 Binary files /dev/null and b/data/mus_over.ogg differ diff --git a/data/mus_prem.ogg b/data/mus_prem.ogg new file mode 100644 index 0000000..a154343 Binary files /dev/null and b/data/mus_prem.ogg differ diff --git a/data/snd_afal.wav b/data/snd_afal.wav new file mode 100644 index 0000000..6449fe3 Binary files /dev/null and b/data/snd_afal.wav differ diff --git a/data/snd_ahit.wav b/data/snd_ahit.wav new file mode 100644 index 0000000..fd4ce34 Binary files /dev/null and b/data/snd_ahit.wav differ diff --git a/data/snd_ajmp.wav b/data/snd_ajmp.wav new file mode 100644 index 0000000..f02e3ae Binary files /dev/null and b/data/snd_ajmp.wav differ diff --git a/data/snd_asht.wav b/data/snd_asht.wav new file mode 100644 index 0000000..f2ba81e Binary files /dev/null and b/data/snd_asht.wav differ diff --git a/data/snd_ast1.wav b/data/snd_ast1.wav new file mode 100644 index 0000000..273fa8c Binary files /dev/null and b/data/snd_ast1.wav differ diff --git a/data/snd_ast2.wav b/data/snd_ast2.wav new file mode 100644 index 0000000..44f2b7b Binary files /dev/null and b/data/snd_ast2.wav differ diff --git a/data/snd_ast3.wav b/data/snd_ast3.wav new file mode 100644 index 0000000..268454d Binary files /dev/null and b/data/snd_ast3.wav differ diff --git a/data/snd_hit.wav b/data/snd_hit.wav new file mode 100644 index 0000000..94b1a84 Binary files /dev/null and b/data/snd_hit.wav differ diff --git a/data/snd_low.wav b/data/snd_low.wav new file mode 100644 index 0000000..0ca68f2 Binary files /dev/null and b/data/snd_low.wav differ diff --git a/data/snd_swch.wav b/data/snd_swch.wav new file mode 100644 index 0000000..e814d37 Binary files /dev/null and b/data/snd_swch.wav differ diff --git a/data/snd_txta.wav b/data/snd_txta.wav new file mode 100644 index 0000000..0ce527a Binary files /dev/null and b/data/snd_txta.wav differ diff --git a/data/snd_txtb.wav b/data/snd_txtb.wav new file mode 100644 index 0000000..25f0f05 Binary files /dev/null and b/data/snd_txtb.wav differ diff --git a/data/snd_txte.wav b/data/snd_txte.wav new file mode 100644 index 0000000..e8ec855 Binary files /dev/null and b/data/snd_txte.wav differ diff --git a/data/snd_txtp.wav b/data/snd_txtp.wav new file mode 100644 index 0000000..9ae6447 Binary files /dev/null and b/data/snd_txtp.wav differ diff --git a/data/tiles.gif b/data/tiles.gif new file mode 100644 index 0000000..1ba5b25 Binary files /dev/null and b/data/tiles.gif differ diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..0b8b474 --- /dev/null +++ b/readme.md @@ -0,0 +1,5 @@ +# Cacaus Arcade + +

+ Va! Anem a vore si fem la conversió del cacaus a un joc arcade +