[WIP] Treballant en el jefe. Per fi! Ja comença a funcionar de nou

This commit is contained in:
2026-04-17 21:22:03 +02:00
parent 956603b99c
commit 82e00e04d1
6 changed files with 348 additions and 120 deletions

View File

@@ -5,6 +5,13 @@ function print_dbg(...)
print("[" .. nombre .. "]", ...)
end
hab1 = 1
tx1 = 1
ty1 = 1
hab2 = 1
tx2 = 1
ty2 = 1
require "pattern"
imp = {}
@@ -17,6 +24,7 @@ function imp.new(_hab,_x,_y)
name="imp",
hab=_hab,
x=world_x, y=world_y,
x_old = 0, y_old = 0,
w=32, h=32,
bb={x=8,y=0,w=16,h=32},
flip=true,
@@ -26,7 +34,7 @@ function imp.new(_hab,_x,_y)
step=0,
moods={stop=0, chase=1, avoid=2, neutral=4},
mood=0, --anterior fight_mode
timers={mood=150,target=250, shot=2500, super=20000, flip_wait=50}, --anterior *_cooldown
timers={mood=150,target=250, shot=100, super=200, flip_wait=50}, --anterior *_cooldown
move_types={free=0, pattern=1, super=2},
move_type=1, -- anterior movement_type
actions={no_action=0, up=1, down=2, left=4, right=8, jump=16, shot=32, super=64, jumpfwd=128},
@@ -40,11 +48,14 @@ function imp.new(_hab,_x,_y)
vmove_space = 1,
falling = 0,
action_event = {},
action = 0,
old_action = 0,
--
moure = noop,
draw=imp.draw,
update=imp.update_normal,
reduce_timers = imp.reduce_timers,
reset_timer = imp.reset_timer,
analyze_env = imp.analyze_env,
choose_action = imp.choose_action,
controller_input = imp.controller_input,
@@ -59,7 +70,13 @@ function imp.new(_hab,_x,_y)
land = imp.land,
next_frame = imp.staying_next_frame,
do_flip = imp.do_flip,
update_action_events = imp.update_action_events,
check_action_event = imp.check_action_event,
add_action_event = imp.add_action_event,
shot = imp.shot,
-- debug
_moure = imp._moure,
_pause = false,
}
end
@@ -94,6 +111,14 @@ function imp:draw() --OK
draw.surf((self.frame&7)*self.w, (self.frame>>cxr2)*self.h, self.w, self.h, scr_x, scr_y, self.w, self.h, self.flip)
pal.subpal(5)
end
draw.rect(scr_x+self.bb.x,scr_y+self.bb.h, self.bb.w, 8,2)
local wtx, wty = coords.room_to_world(hab1, tx1, ty1)
local scr_x, scr_y = viewp:screen_coords( wtx, wty )
draw.rect(scr_x, scr_y, 16, 16, 15)
local wtx, wty = coords.room_to_world(hab2, tx2, ty2)
local scr_x, scr_y = viewp:screen_coords( wtx, wty )
draw.rect(scr_x, scr_y, 16, 16, 13)
end
function imp:hit() -- OK
@@ -129,12 +154,14 @@ function imp:update_hit()
-- Que pasa quan "mor"
end
function imp:update_normal()
print("-------------------------------------------------")
print("")
-- if self.mood~=self.moods.stop then print("TARGET= "..self.pattern:target()) end
-- if self.mood~=self.moods.stop then print("ACTIONS= "..#self.pattern:actions()) end
-- print("")
-- print("TARGET TIMER= "..self.timers.target)
if not self._pause then
-- print("-------------------------------------------------")
-- if self.mood~=self.moods.stop then print("TARGET= "..self.pattern:target()) end
-- if self.mood~=self.moods.stop then print("ACT/EV= "..self.pattern:action().." / "..self.pattern:event()) end
-- if self.mood~=self.moods.stop then print("ACTIONS= "..#self.pattern:actions()) end
self:reduce_timers()
-- Ajustar mood (emocions)
@@ -144,16 +171,21 @@ print("")
-- analisis
self:analyze_env()
self:update_action_events()
-- print_analisis()
-- decisio
self:choose_action()
-- local str_aev = ""
-- for k,v in pairs(self.action_event) do str_aev=str_aev..", "..v end
-- if self.mood~=self.moods.stop then print("TARGET= "..self.pattern:target().." ACTION= "..self.pattern:action().." ACTION EVENT= "..self.pattern:event().." / "..str_aev) end
-- moviment
self:controller_input()
self:moure()
-- Logica per a selecció de frame
self:next_frame()
end
-- colisions en personatges
-- self:colisions()