[WIP] Lluita contra jefes. Càrrega de fase redefinida
This commit is contained in:
@@ -123,6 +123,7 @@ function render_map( sf_map, sf_tiles, x, y, target )
|
||||
view.origin(0,0)
|
||||
end
|
||||
|
||||
|
||||
function load_stage()
|
||||
local stage_init = stages["stage"..stage.."_init"]
|
||||
if stage_init then
|
||||
@@ -134,6 +135,18 @@ function load_stage()
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function load_boss_stage()
|
||||
local stage_boss = stages["stage"..stage.."_boss"]
|
||||
if stage_boss and not scene_running and not stages.loaded_boss then
|
||||
stage_boss()
|
||||
print("Stage "..stage.." Boss loaded")
|
||||
else
|
||||
print("No se ha cargado la fase "..stage)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function viewport_update()
|
||||
-- Moure el viewport
|
||||
local vp_x = viewp.x
|
||||
@@ -204,6 +217,7 @@ end
|
||||
|
||||
function update_game()
|
||||
if stage~=stage_loaded then load_stage() end
|
||||
if stages.boss_ready and not stages.boss_loaded then load_boss_stage() end
|
||||
|
||||
surf.target(0)
|
||||
surf.cls(16)
|
||||
|
||||
@@ -34,10 +34,13 @@ function gota.new(_hab,_x,_y,_freq,_x_offset, _y_offset)
|
||||
update=gota.update_normal,
|
||||
draw=gota.draw_normal,
|
||||
draw_drop= gota.draw_drop,
|
||||
bb={x=4,y=0,w=8,h=12}}
|
||||
bb={x=4,y=0,w=8,h=12},
|
||||
enabled= true,
|
||||
disable_reason="" }
|
||||
end
|
||||
|
||||
function gota:draw_normal()
|
||||
if not self.enabled then return end
|
||||
local x = gota_gif_col*cw
|
||||
local y = gota_gif_row*ch
|
||||
local scr_x, scr_y = viewp:screen_coords( self.x, self.y )
|
||||
@@ -48,6 +51,7 @@ function gota:draw_normal()
|
||||
end
|
||||
|
||||
function gota:update_normal()
|
||||
if not self.enabled then return end
|
||||
self.wait=self.wait+1
|
||||
|
||||
if self.wait==18 then
|
||||
@@ -104,6 +108,7 @@ function gota:hit()
|
||||
end
|
||||
|
||||
function gota:draw_falling()
|
||||
if not self.enabled then return end
|
||||
local gota_x, gota_y = viewp:screen_coords( self.x, self.y )
|
||||
draw.circf( gota_x+4, gota_y+12, 4, 16)
|
||||
draw.circf( gota_x+5, gota_y+13, 3, 11)
|
||||
@@ -111,12 +116,14 @@ function gota:draw_falling()
|
||||
end
|
||||
|
||||
function gota:draw_drop( x, y )
|
||||
if not self.enabled then return end
|
||||
splash_x, splash_y = viewp:screen_coords( x, y )
|
||||
draw.circf( splash_x, splash_y, 2, 16)
|
||||
draw.circf( splash_x, splash_y, 1, 11)
|
||||
end
|
||||
|
||||
function gota:draw_splash()
|
||||
if not self.enabled then return end
|
||||
local splash_L1_x = (self.cx-self.dx)
|
||||
local splash_L2_x = (self.cx-(self.dx/2))
|
||||
local splash_R1_x = (self.cx+self.dx)
|
||||
@@ -131,6 +138,7 @@ function gota:draw_splash()
|
||||
end
|
||||
|
||||
function gota:update_splash()
|
||||
if not self.enabled then return end
|
||||
self.dx=self.dx-1
|
||||
self.dy=self.dy+0.25
|
||||
self.x=self.cx+self.dx
|
||||
|
||||
10
data/imp.lua
10
data/imp.lua
@@ -21,7 +21,8 @@ imp={hab=75,
|
||||
anim={28,29,28,30},
|
||||
bb={x=4,y=0,w=16,h=32},
|
||||
scene_intro=false,
|
||||
scene_object=false}
|
||||
scene_object=false,
|
||||
mode="stop"}
|
||||
|
||||
function imp.reset()
|
||||
imp.hit=imp.hit
|
||||
@@ -83,6 +84,13 @@ function imp.hit()
|
||||
end
|
||||
|
||||
function imp.update()
|
||||
if mode=="chase" then
|
||||
if abad.x<imp.x then
|
||||
imp.x=imp.x-1
|
||||
elseif abad.x>imp.x then
|
||||
imp.x=imp.x+1
|
||||
end
|
||||
end
|
||||
-- imp.wait=imp.wait+1
|
||||
--
|
||||
-- if imp.wait==6 then
|
||||
|
||||
@@ -21,6 +21,11 @@ avatar_imp_y = 96
|
||||
|
||||
avatar_sf=surf.new(avatar_w, avatar_h)
|
||||
|
||||
scene={
|
||||
running = false,
|
||||
stop_music = true
|
||||
}
|
||||
|
||||
scenes={
|
||||
lluita_imp= {
|
||||
{x=avatar_abad_x,y=avatar_abad_y,flip=false,audio="abad",text={"Eh!?","...","Tu qui eres?"},die=20},
|
||||
@@ -162,28 +167,29 @@ scenes={
|
||||
},
|
||||
}
|
||||
|
||||
function start_scene(scene,offset)
|
||||
function start_scene(_scene, offset, stop_music)
|
||||
--bkg=newsurf(128,96)
|
||||
--setdest(bkg)
|
||||
--setsource(0)
|
||||
--draw.surf(0,0,128,96,0,0)
|
||||
--setsource(tiles)
|
||||
--setdest(0)
|
||||
scenes.current_scene=scene
|
||||
scenes.current_scene=_scene
|
||||
scenes.dnum=1
|
||||
scenes.step=0
|
||||
scenes.char=1
|
||||
scenes.wait=0
|
||||
scenes.offset=28
|
||||
scenes.die=scenes.current_scene[scenes.dnum].die or 0
|
||||
if scene[1].musica then
|
||||
if _scene[1].musica then
|
||||
--print(scene[1].musica)
|
||||
music.play(scenes.current_scene[scenes.dnum].musica)
|
||||
end
|
||||
if offset then scenes.offset=offset end
|
||||
-- old_update=game_update
|
||||
-- game_update=update_scene
|
||||
|
||||
scene.running = true
|
||||
if not stop_music then scene.stop_music = false end
|
||||
flow:executar("scene", true); -- guardar l'estat anterior i executar
|
||||
end
|
||||
|
||||
@@ -362,7 +368,7 @@ function update_scene()
|
||||
scenes.die=scenes.die-1
|
||||
if scenes.die==0 then
|
||||
if scenes.dnum==#scenes.current_scene then
|
||||
music.stop()
|
||||
if scene.stop_music then music.stop() end
|
||||
-- if batman.endgame then
|
||||
-- final_init()
|
||||
-- fade.fadeoutin()
|
||||
@@ -401,7 +407,7 @@ function update_scene()
|
||||
controller:check("up") or controller:check("left") or
|
||||
controller:check("right") or key.press(key.RETURN) then
|
||||
if scenes.dnum==#scenes.current_scene then
|
||||
music.stop()
|
||||
if scenes.stop_music then music.stop() end
|
||||
-- if batman.endgame then
|
||||
-- final_init()
|
||||
-- fade.fadeoutin()
|
||||
@@ -421,7 +427,8 @@ function update_scene()
|
||||
end
|
||||
|
||||
function end_scene()
|
||||
scene.running = false
|
||||
flow:finish()
|
||||
end
|
||||
|
||||
flow:registrar("scene",{update_scene})
|
||||
flow:registrar("scene",{update_scene, end_scene})
|
||||
@@ -1,5 +1,8 @@
|
||||
stages = {}
|
||||
|
||||
stages.boss_ready = false
|
||||
stages.boss_loaded = false
|
||||
|
||||
function stages.stage1_init()
|
||||
mapa = stage1_mapa
|
||||
tiletype={void=0,nonpc=1,stair=2,switch=3,half=4,block=5}
|
||||
@@ -108,17 +111,27 @@ function stages.stage1_init()
|
||||
remote_view_init()
|
||||
|
||||
viewp:free_move()
|
||||
|
||||
stages.boss_ready = false
|
||||
stages.boss_loaded = false
|
||||
end
|
||||
|
||||
function stages.stage2_init()
|
||||
print("stage 2 init")
|
||||
end
|
||||
|
||||
function stage1_boss()
|
||||
load_tilemap( sf_mapa, stage1_boss_mapa )
|
||||
-- actors_in_room_backup_and_remove(stage1_boss_mapa.r0.r,stage1_boss_mapa.r1.r)
|
||||
set_actors_enabled_by_room(false, "boss", stage1_boss_mapa.r0.r, stage1_boss_mapa.r1.r)
|
||||
viewp:fixed({l=8,r=44,u=0,d=0})
|
||||
function stages.stage1_boss_ready()
|
||||
stages.boss_ready = true
|
||||
end
|
||||
|
||||
function stages.stage1_boss()
|
||||
if not scene.running and not stages.boss_loaded then
|
||||
set_actors_enabled_by_room(false, "boss", stage1_boss_mapa.r0.r, stage1_boss_mapa.r1.r)
|
||||
load_tilemap( sf_mapa, stage1_boss_mapa )
|
||||
-- actors_in_room_backup_and_remove(stage1_boss_mapa.r0.r,stage1_boss_mapa.r1.r)
|
||||
viewp:fixed({l=8,r=44,u=48,d=0})
|
||||
stages.boss_loaded = true
|
||||
end
|
||||
end
|
||||
|
||||
stage1_mapa={
|
||||
@@ -962,43 +975,61 @@ stage1_boss_mapa = {
|
||||
map = {
|
||||
-- 44
|
||||
{
|
||||
256,256,256, 17, 18, 19, 18, 19, 18, 19, 18, 19,
|
||||
256,256,256, 17,256,256,256,256,256,256,256,256,
|
||||
256,256,256, 17,256,256,256,256,256,256,256,256,
|
||||
256,256,256, 17,256,256,256,256,256,256,256,256,
|
||||
256,256,256, 17,256,256,256,256,256,256,256,256,
|
||||
256,256,256, 17,256,256,256,256,256,256,256,256,
|
||||
256,256,256, 17,256,256,256,256,256,256,256,256,
|
||||
256,256,256, 17,256, 1,256,256,256,256,256,256,
|
||||
256,256,256, 17,256,256, 1,256,256,256,256, 41,
|
||||
256,256,256, 17,256, 1,256,256,256,256,256,256,
|
||||
},
|
||||
-- 45
|
||||
{
|
||||
18, 19, 18, 19, 18, 19, 18, 19, 18, 19, 17,256,
|
||||
256,256,256,256,256,256,256,256,256,256, 17,256,
|
||||
256,256,256,256,256,256,256,256,256,256, 17,256,
|
||||
256,256,256,256,256,256,256,256,256,256, 17,256,
|
||||
256,256,256,256,256,256,256,256,256,256, 17,256,
|
||||
256,256,256,256,256,256,256,256,256,256, 17,256,
|
||||
256,256,256,256,256,256,256,256,256,256, 17,256,
|
||||
256,256,256,256,256,256,256,256, 2,256, 17,256,
|
||||
256,256, 41,256,256,256,256, 2,256,256, 17,256,
|
||||
256,256,256,256,256,256,256,256, 2,256, 17,256,
|
||||
},
|
||||
-- 54
|
||||
{
|
||||
256,256,256, 17,256,256,256,256,256,256,256,256,
|
||||
256,256,256, 17,256,256,256,256,256,256,256,256,
|
||||
256,256,256, 17,256,256,256,256,256,256,256,256,
|
||||
256,256,256, 17,256,256,256,256,256,256,256,256,
|
||||
256,256,256, 17,256,256,256,256,256,256,256,256,
|
||||
256,256,256, 17,256,256, 1,256,256,256,256, 4,
|
||||
256,256,256, 17,256, 1,256,256,256,256,256,256,
|
||||
256,256,256, 17,256,256, 1,256,256,256,256,256,
|
||||
256,256,256, 17,256, 1,256,256,256,256,256,256,
|
||||
256,256,256, 17,256,256, 1,256,256,256,256,256,
|
||||
20, 21, 20, 21, 54, 55, 54, 55, 54, 55, 54, 56,
|
||||
|
||||
},
|
||||
-- 55
|
||||
{
|
||||
256,256,256,256,256,256,256,256,256,256,17,256,
|
||||
256,256,256,256,256,256,256,256,256,256,17,256,
|
||||
256,256,256,256,256,256,256,256,256,256,17,256,
|
||||
256,256,256,256,256,256,256,256,256,256,17,256,
|
||||
256,256,256,256,256,256,256,256,256,256,17,256,
|
||||
22, 22, 5,256,256,256,256, 2,256,256,17,256,
|
||||
256,256,256,256,256,256,256,256, 2,256,17,256,
|
||||
256,256,256,256,256,256,256, 2,256,256,17,256,
|
||||
256,256,256,256,256,256,256,256, 2,256,17,256,
|
||||
256,256,256,256,256,256,256, 2,256,256,17,256,
|
||||
54, 55, 54, 56, 56, 55, 54, 56, 54, 56,55, 54,
|
||||
|
||||
}
|
||||
},
|
||||
-- 64
|
||||
{
|
||||
26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27,
|
||||
26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27,
|
||||
26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27,
|
||||
26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27,
|
||||
256,256,256,256,256,256,256,256,256,256,256,256,
|
||||
256,256,256,256,256,256,256,256,256,256,256,256,
|
||||
},
|
||||
-- 65
|
||||
{
|
||||
26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27,
|
||||
26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27,
|
||||
26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27,
|
||||
26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27,
|
||||
256,256,256,256,256,256,256,256,256,256,256,256,
|
||||
256,256,256,256,256,256,256,256,256,256,256,256,
|
||||
},
|
||||
},
|
||||
r0 = {r=44, x=1, y=1},
|
||||
r1 = {r=55, x=12, y=6}
|
||||
r1 = {r=65, x=12, y=6}
|
||||
}
|
||||
@@ -131,9 +131,9 @@ function triggers:escena_habitacio_batman()
|
||||
end
|
||||
|
||||
function triggers:escena_lluita_imp()
|
||||
stage1_boss()
|
||||
start_scene(scenes.lluita_imp)
|
||||
start_scene(scenes.lluita_imp, nil, false)
|
||||
remove_actor(self)
|
||||
stages.stage1_boss_ready()
|
||||
end
|
||||
|
||||
-- function triggers:teleport_a()
|
||||
|
||||
Reference in New Issue
Block a user