[WIP] Reestructurant codi abans de posar-me en el nivell 2
[NEW] Afegit music_player [NEW] Música de fons des de l'inici
This commit is contained in:
+82
-51
@@ -1,73 +1,75 @@
|
||||
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 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
|
||||
|
||||
intro_wait=40
|
||||
intro_step=0
|
||||
local tiles_file = "tiles.gif"
|
||||
local next_state = "title"
|
||||
|
||||
function draw_escenari ()
|
||||
surf.cls(16)
|
||||
draw_item_intro("marc",false)
|
||||
view.origin(scene_x_offset, scene_y_offset)
|
||||
mapa_draw(10)
|
||||
-- Borrar la porta del mapa
|
||||
draw_item_intro("pas porta")
|
||||
end
|
||||
local intro_wait=40
|
||||
local intro_step=0
|
||||
|
||||
function draw_item_intro( name, flip, mood )
|
||||
if ( name == "abad" ) then
|
||||
-- abad.mood = mood or "normal"
|
||||
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
|
||||
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")
|
||||
-- game_update = intro_intro
|
||||
mapa = stage1_mapa
|
||||
-- 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.source(tiles)
|
||||
surf.target(0)
|
||||
surf.cls(16)
|
||||
fade.fadein()
|
||||
font.current(font_sf)
|
||||
-- flow:add_path({intro_intro, intro_update})
|
||||
|
||||
states:next()
|
||||
end
|
||||
|
||||
function intro_intro()
|
||||
-- print("INTRO_INTRO")
|
||||
intro_wait=1
|
||||
-- game_update = intro_update
|
||||
states:next()
|
||||
fade.fadeoutin()
|
||||
end
|
||||
|
||||
function intro_update()
|
||||
-- print("INTRO_UPDATE")
|
||||
|
||||
if key.press(key.ESCAPE) or pad.press(btnPause) then
|
||||
-- game_init(true)
|
||||
print("INTRO_UPDATE")
|
||||
-- game_update = menu_init
|
||||
-- game_init(true)
|
||||
intro_end()
|
||||
states:next()
|
||||
elseif key.press(key.SPACE) then
|
||||
intro_wait=1
|
||||
end
|
||||
@@ -124,21 +126,50 @@ function intro_update()
|
||||
elseif intro_step==7 then
|
||||
start_scene(scenes.intro_04,58)
|
||||
intro_step=intro_step+1
|
||||
|
||||
-- STEP 8
|
||||
elseif intro_step==8 then
|
||||
-- game_init(true)
|
||||
-- game_update = menu_init
|
||||
intro_end()
|
||||
states:next()
|
||||
end
|
||||
intro_wait=50
|
||||
end
|
||||
end
|
||||
|
||||
function intro_end()
|
||||
print("intro_end")
|
||||
-- print("INTRO_END")
|
||||
fade.fadeoutin()
|
||||
states:executar("title")
|
||||
states:executar(next_state)
|
||||
end
|
||||
|
||||
states:registrar("intro", {intro_init, intro_intro, intro_update})
|
||||
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})
|
||||
|
||||
Reference in New Issue
Block a user