Arranquem!
This commit is contained in:
7
.gitignore
vendored
Normal file
7
.gitignore
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
.DS_STORE
|
||||
release/*
|
||||
*.exe
|
||||
*.dll
|
||||
mini
|
||||
mini_debug
|
||||
data-old
|
||||
32
data/arcade_config.lua
Normal file
32
data/arcade_config.lua
Normal file
@@ -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
|
||||
20
data/audio.lua
Normal file
20
data/audio.lua
Normal file
@@ -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"
|
||||
99
data/fade.lua
Normal file
99
data/fade.lua
Normal file
@@ -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
|
||||
|
||||
}
|
||||
19
data/fps.lua
Normal file
19
data/fps.lua
Normal file
@@ -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()
|
||||
5
data/game.ini
Normal file
5
data/game.ini
Normal file
@@ -0,0 +1,5 @@
|
||||
title=Cacaus Arcade
|
||||
config=cacaus_arcade
|
||||
width=256
|
||||
height=192
|
||||
zoom=3
|
||||
143
data/intro.lua
Normal file
143
data/intro.lua
Normal file
@@ -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
|
||||
118
data/main.lua
Normal file
118
data/main.lua
Normal file
@@ -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
|
||||
BIN
data/mus_alie.ogg
Normal file
BIN
data/mus_alie.ogg
Normal file
Binary file not shown.
BIN
data/mus_batm.ogg
Normal file
BIN
data/mus_batm.ogg
Normal file
Binary file not shown.
BIN
data/mus_life.ogg
Normal file
BIN
data/mus_life.ogg
Normal file
Binary file not shown.
BIN
data/mus_menu.ogg
Normal file
BIN
data/mus_menu.ogg
Normal file
Binary file not shown.
BIN
data/mus_over.ogg
Normal file
BIN
data/mus_over.ogg
Normal file
Binary file not shown.
BIN
data/mus_prem.ogg
Normal file
BIN
data/mus_prem.ogg
Normal file
Binary file not shown.
BIN
data/snd_afal.wav
Normal file
BIN
data/snd_afal.wav
Normal file
Binary file not shown.
BIN
data/snd_ahit.wav
Normal file
BIN
data/snd_ahit.wav
Normal file
Binary file not shown.
BIN
data/snd_ajmp.wav
Normal file
BIN
data/snd_ajmp.wav
Normal file
Binary file not shown.
BIN
data/snd_asht.wav
Normal file
BIN
data/snd_asht.wav
Normal file
Binary file not shown.
BIN
data/snd_ast1.wav
Normal file
BIN
data/snd_ast1.wav
Normal file
Binary file not shown.
BIN
data/snd_ast2.wav
Normal file
BIN
data/snd_ast2.wav
Normal file
Binary file not shown.
BIN
data/snd_ast3.wav
Normal file
BIN
data/snd_ast3.wav
Normal file
Binary file not shown.
BIN
data/snd_hit.wav
Normal file
BIN
data/snd_hit.wav
Normal file
Binary file not shown.
BIN
data/snd_low.wav
Normal file
BIN
data/snd_low.wav
Normal file
Binary file not shown.
BIN
data/snd_swch.wav
Normal file
BIN
data/snd_swch.wav
Normal file
Binary file not shown.
BIN
data/snd_txta.wav
Normal file
BIN
data/snd_txta.wav
Normal file
Binary file not shown.
BIN
data/snd_txtb.wav
Normal file
BIN
data/snd_txtb.wav
Normal file
Binary file not shown.
BIN
data/snd_txte.wav
Normal file
BIN
data/snd_txte.wav
Normal file
Binary file not shown.
BIN
data/snd_txtp.wav
Normal file
BIN
data/snd_txtp.wav
Normal file
Binary file not shown.
BIN
data/tiles.gif
Normal file
BIN
data/tiles.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 11 KiB |
Reference in New Issue
Block a user