e0825e5bbb
[NEW] Afegit music_player [NEW] Música de fons des de l'inici
176 lines
4.9 KiB
Lua
176 lines
4.9 KiB
Lua
|
|
local abad ={ x=0, y= 0, w=32, h=32, dx= 88, dy=48, dw=32, dh=32 }
|
|
local batman={ x=0, y= 96, w=32, h=32, dx=164, dy=48, dw=32, dh=32 }
|
|
local cacaus={ x=224, y=176, w=32, h=16, dx=152, dy=64, dw=32, dh=16 }
|
|
local cacaus_trans={ x=192, y=176, w=16, h=8, dx=65, dy=56, dw=16, dh=8 }
|
|
local marc={ x=30, y=6, w=198, h=102, color=2 }
|
|
local pas_porta={ x=146, y=48, w=14, h=32, color=16 }
|
|
|
|
local scene_x_offset = 32
|
|
local scene_y_offset = 8
|
|
|
|
local tiles_file = "tiles.gif"
|
|
local next_state = "title"
|
|
|
|
local intro_wait=40
|
|
local intro_step=0
|
|
|
|
local intro_mapa_room_cols = 12; -- en quantitat de tiles
|
|
local intro_mapa_room_rows = 6; -- en quantitat de tiles
|
|
local intro_mapa_rooms_per_piso = 1
|
|
local intro_mapa_pisos = 1
|
|
local intro_mapa_empty_tile = 256
|
|
|
|
local intro_mapa={
|
|
-- 1
|
|
{
|
|
256, 66, 26, 27, 28, 29, 28, 29, 26, 27, 28, 29,
|
|
256,256,256, 24,256,256,256,256,256, 25,256,256,
|
|
64, 68,256,256,256,256,256,256,256, 25,256,256,
|
|
256,256, 66, 24,256,121,256,256,256, 38,256,256,
|
|
256, 66,256, 24,101,102,103,256,256, 38,256,256,
|
|
66,256,256, 24, 28, 29, 28, 29, 28, 29, 28, 29,
|
|
},
|
|
}
|
|
|
|
function intro_init()
|
|
-- print("INTRO_INIT")
|
|
mapa = intro_mapa
|
|
mapa_room_cols = intro_mapa_room_cols
|
|
mapa_room_rows = intro_mapa_room_rows
|
|
mapa_rooms_per_piso = intro_mapa_rooms_per_piso
|
|
mapa_pisos = intro_mapa_pisos
|
|
mapa_empty_tile = intro_mapa_empty_tile
|
|
mapa_surface_init()
|
|
load_tilemap( sf_mapa )
|
|
|
|
tiles=surf.load(tiles_file)
|
|
surf.source(tiles)
|
|
local paleta=pal.load(tiles_file)
|
|
pal.set(paleta)
|
|
|
|
intro_wait=400
|
|
surf.target(0)
|
|
surf.cls(16)
|
|
fade.fadein()
|
|
font.current(font_sf)
|
|
|
|
states:next()
|
|
end
|
|
|
|
function intro_intro()
|
|
-- print("INTRO_INTRO")
|
|
intro_wait=1
|
|
states:next()
|
|
fade.fadeoutin()
|
|
end
|
|
|
|
function intro_update()
|
|
-- print("INTRO_UPDATE")
|
|
|
|
if key.press(key.ESCAPE) or pad.press(btnPause) then
|
|
states:next()
|
|
elseif key.press(key.SPACE) then
|
|
intro_wait=1
|
|
end
|
|
|
|
intro_wait=intro_wait-1
|
|
if intro_wait==0 then
|
|
-- == INTRO_01
|
|
-- STEP 0
|
|
if intro_step==0 then
|
|
draw_escenari()
|
|
draw_item_intro("abad", false)
|
|
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
|
|
|
|
-- == INTRO_02
|
|
-- STEP 2
|
|
elseif intro_step==2 then
|
|
draw_escenari()
|
|
draw_item_intro("abad", true, "sorpresa")
|
|
draw_item_intro("cacaus trans", 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
|
|
|
|
-- == INTRO_03
|
|
-- 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
|
|
|
|
-- == INTRO_04
|
|
-- 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
|
|
states:next()
|
|
end
|
|
intro_wait=50
|
|
end
|
|
end
|
|
|
|
function intro_end()
|
|
-- print("INTRO_END")
|
|
fade.fadeoutin()
|
|
states:executar(next_state)
|
|
end
|
|
|
|
function draw_escenari ()
|
|
surf.cls(16)
|
|
draw_item_intro("marc",false)
|
|
view.origin(scene_x_offset, scene_y_offset)
|
|
mapa_draw(0)
|
|
-- Borrar la porta del mapa
|
|
draw_item_intro("pas porta")
|
|
end
|
|
|
|
function draw_item_intro( name, flip, mood )
|
|
if ( name == "abad" ) then
|
|
draw.surf(abad.x, abad.y, abad.w, abad.h, abad.dx, abad.dy, abad.dw, abad.dh, flip)
|
|
abad_add_mood(abad.dx,0,abad.dy,0,flip,mood)
|
|
|
|
elseif (name == "batman" ) then
|
|
draw.surf(batman.x, batman.y, batman.w, batman.h, batman.dx, batman.dy, batman.dw, batman.dh, flip)
|
|
|
|
elseif (name == "cacaus" ) then
|
|
draw.surf(cacaus.x, cacaus.y, cacaus.w, cacaus.h, cacaus.dx, cacaus.dy, cacaus.dw, cacaus.dh, flip)
|
|
|
|
elseif (name == "cacaus trans" ) then
|
|
draw.surf(cacaus_trans.x, cacaus_trans.y, cacaus_trans.w, cacaus_trans.h, cacaus_trans.dx, cacaus_trans.dy, cacaus_trans.dw, cacaus_trans.dh, flip)
|
|
|
|
elseif (name == "marc" ) then
|
|
draw.rect(marc.x, marc.y, marc.w, marc.h, marc.color)
|
|
|
|
elseif (name == "pas porta" ) then
|
|
draw.rectf(pas_porta.x, pas_porta.y, pas_porta.w, pas_porta.h, pas_porta.color)
|
|
end
|
|
end
|
|
|
|
|
|
states:registrar("intro", {intro_init, intro_intro, intro_update, intro_end})
|