[WIP] Lluita contra jefes

This commit is contained in:
2026-04-04 20:45:14 +02:00
parent 205586cc77
commit 9bb372a70b
6 changed files with 209 additions and 112 deletions

View File

@@ -86,6 +86,18 @@ function coords.room_to_coord ( room, center )
return x, y return x, y
end end
function coords.room_to_mini_tile( room, x, y )
-- room=room-1
x=x-1
y=y-1
local tx = room % coords.ROOMS_PER_FLOOR -- columna de l'habitació
tx = tx * coords.ROOM_COLS+x
local ty = math.floor(room / coords.ROOMS_PER_FLOOR) -- fila de l'habitació
ty = ty * coords.ROOM_ROWS+y
return tx, ty
end
-- local TILE_W = arcade_config.tiles_width -- local TILE_W = arcade_config.tiles_width
-- local TILE_H = arcade_config.tiles_height -- local TILE_H = arcade_config.tiles_height
-- local ROOM_COLS = mapa_room_cols -- local ROOM_COLS = mapa_room_cols

View File

@@ -18,6 +18,8 @@ require "imp"
require "stage1" require "stage1"
local DEBUG = true
local tile_w = arcade_config.tiles_width local tile_w = arcade_config.tiles_width
local tile_h = arcade_config.tiles_height local tile_h = arcade_config.tiles_height
local res_w = arcade_config.resolucion.width local res_w = arcade_config.resolucion.width
@@ -103,96 +105,8 @@ function game_init(menu)
abad_init() abad_init()
table.insert(actors,abad) table.insert(actors,abad)
llibre.init()
table.insert(actors,llibre)
gorro.init()
table.insert(actors,gorro)
peu.init()
table.insert(actors,peu)
premiere.init()
table.insert(actors,premiere)
elalien.init()
table.insert(actors,elalien)
imp.init()
table.insert(actors,imp)
--batman
bol.init()
table.insert(actors,bol)
table.insert( actors, gota.new(70,5,1,20) )
table.insert( actors, gota.new(70,9,1,30) )
table.insert( actors, gota.new(63,5,1,25,2,-7) )
table.insert( actors, gota.new(63,9,1,20,0,-8) )
table.insert( actors, gota.new(64,3,1,10,0,-6) )
table.insert( actors, gota.new(64,6,1,25,-1,-5) )
table.insert( actors, gota.new(65,7,1,10,0,-7) )
table.insert( actors, gota.new(65,8,1,25,0,-7) )
table.insert( actors, gota.new(66,3,1,10,0,-7) )
table.insert( actors, gota.new(66,4,1,15,0,-7) )
table.insert( actors, gota.new(77,2,1,30,-5,-7) )
table.insert( actors, gota.new(77,9,1,25,-5,-7) )
-- FOC?
table.insert(actors,invisible.new(77,5,4))
table.insert(actors,invisible.new(77,6,4))
table.insert(actors,invisible.new(58,2,4))
table.insert(actors,invisible.new(58,3,4))
table.insert( actors, caco.new(13,3,2,true ) )
table.insert( actors, caco.new(17,3,2,false) )
table.insert( actors, caco.new(20,3,2,false) )
table.insert( actors, caco.new(26,3,2,false) )
table.insert( actors, caco.new(37,3,2,false) )
table.insert( actors, caco.new(41,3,2,false) )
table.insert( actors, caco.new(50,3,2,false) )
table.insert( actors, caco.new(57,3,2,false) )
table.insert( actors, caco.new(61,3,2,false) )
table.insert( actors, zombie.new(2, 3, 3,false) )
table.insert( actors, zombie.new(28, 3, 3,false) )
table.insert( actors, zombie.new(32, 3, 3,false) )
table.insert( actors, zombie.new(44, 3, 3,false) )
table.insert( actors, zombie.new(46, 3, 3,false) )
table.insert( actors, zombie.new(54, 3, 3,false) )
table.insert( actors, zombie.new(68, 3, 3,false) )
table.insert( actors, zombie.new(73, 3, 3,false) )
-- TRIGGERS
-- if not menu then table.insert(actors,trigger.new(10,57,32,triggers.escena_abad_inici)) end
table.insert( actors, trigger.new(10,7,3,triggers.escena_abad_inici,"inici"))
table.insert( actors, trigger.new(11,2,3,triggers.escena_abad_corfes,"corfes"))
table.insert( actors, trigger.new(31,1,3,triggers.escena_abad_portes,"portes"))
table.insert( actors, trigger.new(31,6,3,triggers.escena_abad_portes,"portes"))
table.insert( actors, trigger.new(71,7,3,triggers.escena_abad_portes,"portes"))
table.insert( actors, trigger.new(53,5,3,triggers.escena_abad_porta_casa,"porta casa"))
table.insert( actors, trigger.new(56,4,3,triggers.escena_abad_porta_batman,"porta batman"))
table.insert( actors, trigger.new(19,32,32,triggers.escena_habitacio_batman,"habitacio batman"))
--
table.insert( actors, trigger.new(55,1,3,triggers.escena_lluita_imp,"lluita imp"))
-- table.insert(actors,trigger.new(14,40,32,triggers.teleport_a))
-- table.insert(actors,trigger.new(67,8,32,triggers.teleport_b))
-- table.insert(actors,trigger.new(29,40,32,triggers.teleport_c))
-- table.insert(actors,trigger.new(61,8,32,triggers.teleport_d))
score.create() score.create()
local abad_x, abad_y = coords.room_to_world ( 10, 4, 3 )
-- local abad_x, abad_y = coords.room_to_world ( 54, 8, 3 )
abad:move(abad_x, abad_y)
abad_make_safe( true )
local scr_ax, scr_ay = viewp:screen_coords(abad_x, abad_y)
-- game_update=update_game -- game_update=update_game
flow:next() flow:next()
end end
@@ -219,6 +133,7 @@ function load_stage()
end end
function viewport_update() function viewport_update()
-- Moure el viewport
local vp_x = viewp.x local vp_x = viewp.x
local vp_y = viewp.y local vp_y = viewp.y
@@ -289,18 +204,18 @@ function update_game()
surf.target(0) surf.target(0)
surf.cls(16) surf.cls(16)
-- special_keys()
world_update() world_update()
-- Moure el viewport
viewport_update() viewport_update()
world_draw() world_draw()
score.draw() score.draw()
-- debug_info() if DEBUG then
special_keys()
debug_info()
end
end end
function pause() function pause()
@@ -397,7 +312,7 @@ function special_keys()
end end
if key.press(key.N0) then if key.press(key.N0) then
-- abad go to room -- abad go to room
local abad_x, abad_y = coords.room_to_world ( 70, 6, 3 ) local abad_x, abad_y = coords.room_to_world ( 54, 6, 3 )
print(abad_x..", "..abad_y) print(abad_x..", "..abad_y)
abad:move(abad_x, abad_y) abad:move(abad_x, abad_y)
local scr_ax, scr_ay = viewp:screen_coords(abad_x, abad_y) local scr_ax, scr_ay = viewp:screen_coords(abad_x, abad_y)

View File

@@ -124,7 +124,7 @@ function map_to_editor_tile(map_tile)
return result return result
end end
function load_tilemap( sf_mapa ) function load_tilemap( sf_mapa, replace_map )
local mapa_tw, mapa_th = surf.size(sf_mapa) local mapa_tw, mapa_th = surf.size(sf_mapa)
local nrooms = mapa_rooms_per_piso*mapa_pisos local nrooms = mapa_rooms_per_piso*mapa_pisos
local x = 0 local x = 0
@@ -133,6 +133,7 @@ function load_tilemap( sf_mapa )
local xroom = 0 local xroom = 0
map.surf(sf_mapa) map.surf(sf_mapa)
if replace_map==nil then
for ty=0,mapa_th-1 do for ty=0,mapa_th-1 do
if y == mapa_room_rows then if y == mapa_room_rows then
yroom = yroom + mapa_rooms_per_piso yroom = yroom + mapa_rooms_per_piso
@@ -150,6 +151,37 @@ function load_tilemap( sf_mapa )
end end
y = y +1 y = y +1
end end
else
local mapa_x0, mapa_y0 = coords.room_to_mini_tile( replace_map.r0.r, replace_map.r0.x, replace_map.r0.y )
local mapa_x1, mapa_y1 = coords.room_to_mini_tile( replace_map.r1.r, replace_map.r1.x, replace_map.r1.y )
local replace_rooms_per_piso = ((replace_map.r1.r-replace_map.r0.r)+1)%mapa_rooms_per_piso
-- print(mapa_x0..", "..mapa_y0)
-- print(mapa_x1..", "..mapa_y1)
-- print(mapa_x1-mapa_x0..", "..mapa_y1-mapa_y0)
print(replace_rooms_per_piso)
y = 0
for ty=mapa_y0,mapa_y1 do --24 -> 41 = 17 (18)
if y == mapa_room_rows then
yroom = yroom + replace_rooms_per_piso
y = 0
end
xroom = yroom
for tx=mapa_x0, mapa_x1 do -- 36 -> 59 = 23 (24)
print("ROOM= "..xroom.." ( "..x..", "..y.." ) <= "..(1+xroom)..", "..(1+x+y*mapa_room_cols))
-- print(replace_map.map[1+xroom][1+x+y*mapa_room_cols])
local tile=editor_to_map_tile(replace_map.map[1+xroom][1+x+y*mapa_room_cols])
map.tile(tx, ty, tile)
x = x + 1
if x == mapa_room_cols then
x = 0
xroom = xroom + 1
end
end
y = y +1
end
end
end end
-- DEBUG -- DEBUG

View File

@@ -87,7 +87,7 @@ function mini.init()
surf.target(0) surf.target(0)
surf.cls(16) surf.cls(16)
flow:executar("logo") flow:executar("game")
end end
function mini.update() function mini.update()

View File

@@ -6,12 +6,104 @@ function stages.stage1_init()
mapa.wait=0 mapa.wait=0
mapa.step=0 mapa.step=0
load_tilemap( sf_mapa ) load_tilemap( sf_mapa )
llibre.init()
table.insert(actors,llibre)
gorro.init()
table.insert(actors,gorro)
peu.init()
table.insert(actors,peu)
premiere.init()
table.insert(actors,premiere)
elalien.init()
table.insert(actors,elalien)
imp.init()
table.insert(actors,imp)
--batman
bol.init()
table.insert(actors,bol)
table.insert( actors, gota.new(70,5,1,20) )
table.insert( actors, gota.new(70,9,1,30) )
table.insert( actors, gota.new(63,5,1,25,2,-7) )
table.insert( actors, gota.new(63,9,1,20,0,-8) )
table.insert( actors, gota.new(64,3,1,10,0,-6) )
table.insert( actors, gota.new(64,6,1,25,-1,-5) )
table.insert( actors, gota.new(65,7,1,10,0,-7) )
table.insert( actors, gota.new(65,8,1,25,0,-7) )
table.insert( actors, gota.new(66,3,1,10,0,-7) )
table.insert( actors, gota.new(66,4,1,15,0,-7) )
table.insert( actors, gota.new(77,2,1,30,-5,-7) )
table.insert( actors, gota.new(77,9,1,25,-5,-7) )
-- FOC?
table.insert(actors,invisible.new(77,5,4))
table.insert(actors,invisible.new(77,6,4))
table.insert(actors,invisible.new(58,2,4))
table.insert(actors,invisible.new(58,3,4))
table.insert( actors, caco.new(13,3,2,true ) )
table.insert( actors, caco.new(17,3,2,false) )
table.insert( actors, caco.new(20,3,2,false) )
table.insert( actors, caco.new(26,3,2,false) )
table.insert( actors, caco.new(37,3,2,false) )
table.insert( actors, caco.new(41,3,2,false) )
table.insert( actors, caco.new(50,3,2,false) )
table.insert( actors, caco.new(57,3,2,false) )
table.insert( actors, caco.new(61,3,2,false) )
table.insert( actors, zombie.new(2, 3, 3,false) )
table.insert( actors, zombie.new(28, 3, 3,false) )
table.insert( actors, zombie.new(32, 3, 3,false) )
table.insert( actors, zombie.new(44, 3, 3,false) )
table.insert( actors, zombie.new(46, 3, 3,false) )
table.insert( actors, zombie.new(54, 3, 3,false) )
table.insert( actors, zombie.new(68, 3, 3,false) )
table.insert( actors, zombie.new(73, 3, 3,false) )
-- TRIGGERS
-- if not menu then table.insert(actors,trigger.new(10,57,32,triggers.escena_abad_inici)) end
table.insert( actors, trigger.new(10,7,3,triggers.escena_abad_inici,"inici"))
table.insert( actors, trigger.new(11,2,3,triggers.escena_abad_corfes,"corfes"))
table.insert( actors, trigger.new(31,1,3,triggers.escena_abad_portes,"portes"))
table.insert( actors, trigger.new(31,6,3,triggers.escena_abad_portes,"portes"))
table.insert( actors, trigger.new(71,7,3,triggers.escena_abad_portes,"portes"))
table.insert( actors, trigger.new(53,5,3,triggers.escena_abad_porta_casa,"porta casa"))
table.insert( actors, trigger.new(56,4,3,triggers.escena_abad_porta_batman,"porta batman"))
table.insert( actors, trigger.new(19,32,32,triggers.escena_habitacio_batman,"habitacio batman"))
--
table.insert( actors, trigger.new(55,1,3,triggers.escena_lluita_imp,"lluita imp"))
-- table.insert(actors,trigger.new(14,40,32,triggers.teleport_a))
-- table.insert(actors,trigger.new(67,8,32,triggers.teleport_b))
-- table.insert(actors,trigger.new(29,40,32,triggers.teleport_c))
-- table.insert(actors,trigger.new(61,8,32,triggers.teleport_d))
local abad_x, abad_y = coords.room_to_world ( 10, 4, 3 )
-- local abad_x, abad_y = coords.room_to_world ( 54, 8, 3 )
abad:move(abad_x, abad_y)
abad_make_safe( true )
local scr_ax, scr_ay = viewp:screen_coords(abad_x, abad_y)
end end
function stages.stage2_init() function stages.stage2_init()
print("stage 2 init") print("stage 2 init")
end end
function stage1_boss()
load_tilemap( sf_mapa, stage1_boss_mapa )
end
stage1_mapa={ stage1_mapa={
-- 1 -- 1
{ {
@@ -841,3 +933,48 @@ stage1_mapa={
}, },
} }
stage1_boss_mapa = {
map = {
-- 44
{
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,
},
-- 45
{
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,
},
-- 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,
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,
54, 55, 54, 56, 56, 55, 54, 56, 54, 56,55, 54,
}
},
r0 = {r=44, x=1, y=1},
r1 = {r=55, x=12, y=6}
}

View File

@@ -18,8 +18,8 @@ end
function trigger:draw() function trigger:draw()
-- do nothing -- do nothing
-- local scr_x, scr_y = viewp:screen_coords( self.x, self.y ) local scr_x, scr_y = viewp:screen_coords( self.x, self.y )
-- draw.rect(scr_x,scr_y,self.w,self.h,3) draw.rect(scr_x,scr_y,self.w,self.h,3)
end end
function trigger:update() function trigger:update()
@@ -89,6 +89,7 @@ function triggers:escena_habitacio_batman()
end end
function triggers:escena_lluita_imp() function triggers:escena_lluita_imp()
stage1_boss()
start_scene(scenes.lluita_imp) start_scene(scenes.lluita_imp)
remove_actor(self) remove_actor(self)
end end