[WIP] Lluita contra jefes.

+ Redisseny de mapa
+ Ajustada la vista abans del combat i fixada en la vertical
[NEW] Objecte point
This commit is contained in:
2026-04-06 23:30:53 +02:00
parent a481d3798b
commit f93c9b6c55
7 changed files with 65 additions and 25 deletions

View File

@@ -199,6 +199,18 @@ function world_draw()
-- Pintar la finestra del mon -- Pintar la finestra del mon
render_map(sf_mapa, tiles, viewp.x, viewp.y) render_map(sf_mapa, tiles, viewp.x, viewp.y)
if #stages.boss_hot_points>0 then
for _, p in pairs(stages.boss_hot_points) do
p:draw()
end
-- local world_x, world_y = coords.room_to_world(45,2,1)
-- local scr_x, scr_y = viewp:screen_coords( world_x, world_y )
-- draw.line(scr_x, scr_y, scr_x, scr_y+25, 12)
-- draw.line(scr_x, scr_y+25, scr_x+15, scr_y+25, 12)
-- draw.line(scr_x+15, scr_y+25, scr_x+15, scr_y+35, 12)
-- draw.line(scr_x+15, scr_y+35, scr_x+45, scr_y+35, 12)
end
-- pintar warps -- pintar warps
for key,warp in pairs(warp.warp_list) do for key,warp in pairs(warp.warp_list) do
if viewp:inside(warp.x, warp.y, warp.w, warp.h) then if viewp:inside(warp.x, warp.y, warp.w, warp.h) then

View File

@@ -50,7 +50,7 @@ function imp.new(_hab, _x, _y)
step=0, step=0,
hurting=0, hurting=0,
jumpfwd=false, jumpfwd=false,
step_length=0.6, step_length=0.7,
vmove_space=1, vmove_space=1,
max_jump_height=24, max_jump_height=24,
jump_height=0, jump_height=0,
@@ -225,12 +225,6 @@ msg_print(0,0,"state_walking",true)
self.wait=self.wait+1 self.wait=self.wait+1
-- representació del moviment -- representació del moviment
-- if self.wait==6 then
-- self.wait=0
-- self.step=(self.step+1)%2
-- self.frame=self.anim[self.step+1]
-- end
-- Selecció de frame -- Selecció de frame
if self.wait==6 then if self.wait==6 then
self.wait=0 self.wait=0
@@ -258,8 +252,6 @@ function imp:state_falling()
msg_print(0,0,"state_falling",true) msg_print(0,0,"state_falling",true)
self:reduce_cooldown() self:reduce_cooldown()
-- print("state_falling")
self.frame=30 self.frame=30
self.wait=self.wait+1 self.wait=self.wait+1
@@ -380,8 +372,6 @@ msg_print(0,0,"move",true)
self.action = self:movement(abad) self.action = self:movement(abad)
-- print(action)
if self.action == "right" or self.action == "left" then if self.action == "right" or self.action == "left" then
self.update=imp.state_walking self.update=imp.state_walking
-- abad.flip=false -- abad.flip=false

View File

@@ -16,6 +16,7 @@ require "title"
require "game" require "game"
require "opcions" require "opcions"
require "opcions_input" require "opcions_input"
require "point"
--require "fps" --require "fps"
--require "menu" --require "menu"

26
data/point.lua Normal file
View File

@@ -0,0 +1,26 @@
point={}
function point.new(_hab,_x,_y,_x_offset,_y_offset,_id)
local world_x, world_y = coords.room_to_world(_hab,_x,_y)
_x_offset = _x_offset or 0
_y_offset = _y_offset or 0
return {name="point",
id=_id,
hab=_hab,
x=world_x+_x_offset,
y=world_y+_y_offset,
w=8,
h=8,
draw=point.draw,
}
end
function point:draw()
local scr_x, scr_y = viewp:screen_coords( self.x, self.y )
-- debug rect
draw.rect(scr_x,scr_y,self.w,self.h,3)
end
function point:update()
-- do nothing
end

View File

@@ -2,6 +2,7 @@ stages = {}
stages.boss_ready = false stages.boss_ready = false
stages.boss_loaded = false stages.boss_loaded = false
stages.boss_hot_points = {}
boss = nil boss = nil
function stages.stage1_init() function stages.stage1_init()
@@ -130,11 +131,18 @@ function stages.stage1_boss()
set_actors_enabled_by_room(false, "boss", 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)
load_tilemap( sf_mapa, stage1_boss_mapa ) load_tilemap( sf_mapa, stage1_boss_mapa )
-- actors_in_room_backup_and_remove(stage1_boss_mapa.r0.r,stage1_boss_mapa.r1.r) -- 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}) -- viewp:fixed({l=8,r=44,u=48,d=0}, viewp.x, viewp.y-48)
-- viewp:fixed({l=8,r=44,u=0,d=0})
stages.boss_loaded = true stages.boss_loaded = true
boss.reason="" boss.reason=""
boss.enabled=true boss.enabled=true
boss:fight() boss:fight()
table.insert(stages.boss_hot_points, point.new(54,5,4,12,8,"P1"))
table.insert(stages.boss_hot_points, point.new(44,5,3,12,8,"P2"))
table.insert(stages.boss_hot_points, point.new(55,7,4,12,8,"P3"))
table.insert(stages.boss_hot_points, point.new(45,7,3,12,8,"P4"))
table.insert(stages.boss_hot_points, point.new(44,12,5,12,8,"P5"))
table.insert(stages.boss_hot_points, point.new(54,12,4,12,8,"P6"))
end end
end end
@@ -983,23 +991,23 @@ stage1_boss_mapa = {
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, 1,256,256,256,256,256,256,
256,256,256, 17,256,256, 1,256,256,256,256, 41, 256,256,256, 17,112,256, 1,256,256,256,256,112,
256,256,256, 17,256, 1,256,256,256,256,256,256, 256,256,256, 17,256, 1,256,256,256,256,256,256,
}, },
-- 45 -- 45
{ {
18, 19, 18, 19, 18, 19, 18, 19, 18, 19, 17,256, 18, 19, 18, 19, 18, 19, 18, 19, 18, 19, 17,256,
256,256,256,256,256,256,256,256,256,256, 17,256, 69,256,256, 68,256, 67,256,256,256,256, 17,256,
256,256,256,256,256,256,256,256,256,256, 17,256, 256, 69, 64, 66,256,256,256,256,256,256, 17,256,
256,256,256,256,256,256,256,256, 2,256, 17,256, 256, 69, 69, 69,256, 65,256,256, 2,256, 17,256,
256,256, 41,256,256,256,256, 2,256,256, 17,256, 256,256,112,256, 69, 69,256, 2,256,112, 17,256,
256,256,256,256,256,256,256,256, 2,256, 17,256, 256,256,256,256,256,256,256,256, 2,256, 17,256,
}, },
-- 54 -- 54
{ {
256,256,256, 17,256,256, 1,256,256,256,256, 4, 256,256,256, 17,112,256, 1,256,256,256,256, 4,
256,256,256, 17,256, 1,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,256, 256,256,256, 17,112,256, 1,256,256, 1,256,256,
256,256,256, 17,256, 1,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,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, 20, 21, 20, 21, 54, 55, 54, 55, 54, 55, 54, 56,
@@ -1007,9 +1015,9 @@ stage1_boss_mapa = {
}, },
-- 55 -- 55
{ {
22, 22, 5,256,256,256,256, 2,256,256,17,256, 22, 22, 5,256,256,256,256, 2,256,112,17,256,
256,256,256,256,256,256,256,256, 2,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, 2,256,256, 2,256,112,17,256,
256,256,256,256,256,256,256,256, 2,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, 2,256,256,17,256,
54, 55, 54, 56, 56, 55, 54, 56, 54, 56,55, 54, 54, 55, 54, 56, 56, 55, 54, 56, 54, 56,55, 54,

View File

@@ -131,6 +131,7 @@ function triggers:escena_habitacio_batman()
end end
function triggers:escena_lluita_imp() function triggers:escena_lluita_imp()
viewp:fixed({l=8,r=44,u=0,d=0}, viewp.x, viewp.y-48)
start_scene(scenes.lluita_imp, nil, false) start_scene(scenes.lluita_imp, nil, false)
remove_actor(self) remove_actor(self)
stages.stage1_boss_ready() stages.stage1_boss_ready()

View File

@@ -24,9 +24,11 @@ function viewport.new(_width, _height)
} }
end end
function viewport:fixed(range) function viewport:fixed(range, _x, _y)
self.range = range self.range = range
self.fixed_coord = {x=self.x, y=self.y} _x = _x or self.x
_y = _y or self.y
self.fixed_coord = {x=_x, y=_y}
end end
function viewport:free_move() function viewport:free_move()