[WIP] Treballant en el jefe. Tram final

This commit is contained in:
2026-04-18 01:51:00 +02:00
parent 5843953b7b
commit 8f65666a06
4 changed files with 87 additions and 62 deletions

View File

@@ -38,13 +38,14 @@ function fireball.draw()
draw.circf(scr_x,scr_y,8*fireball.size,16) draw.circf(scr_x,scr_y,8*fireball.size,16)
draw.circf(scr_x,scr_y,6*fireball.size,3) draw.circf(scr_x,scr_y,6*fireball.size,3)
draw.circf(scr_x,scr_y,2*fireball.size,8) draw.circf(scr_x,scr_y,2*fireball.size,8)
-- draw.rect(scr_x-5*fireball.size,scr_y-5*fireball.size,5*fireball.size*2,5*fireball.size*2,2)
end end
function fireball.update() function fireball.update()
if fireball.power==2 and fireball.power>fireball.size then if fireball.power==2 and fireball.power>fireball.size then
fireball.wait = fireball.wait + 1 fireball.wait = fireball.wait + 1
fireball.x1=abad.x+abad.bb.x+(abad.bb.w//2) fireball.x1=abad.x+abad.bb.x+(abad.bb.w//2)
fireball.y1=abad.y fireball.y1=abad.y+(abad.bb.h/2)
if abad.x<fireball.x then if abad.x<fireball.x then
fireball.step_length_x = -1 fireball.step_length_x = -1
else else

View File

@@ -1,12 +1,12 @@
function imp:_moure( foo, name ) -- function imp:_moure( foo, name )
-- name = name or "anonymous" -- -- name = name or "anonymous"
-- if not foo then -- -- if not foo then
-- print_dbg(name.." not found") -- -- print_dbg(name.." not found")
-- else -- -- else
-- print_dbg(name) -- -- print_dbg(name)
-- end -- -- end
self.moure = foo -- self.moure = foo
end -- end
function noop () function noop ()
end end
@@ -25,6 +25,12 @@ if DEBUG_FN_NAME then print_dbg("reduce_timers") end
if (val-1)<0 then self.timers[key] = 0 end if (val-1)<0 then self.timers[key] = 0 end
end end
end end
if self.invencible and self.invencible_time >0 then
self.invencible_time = self.invencible_time - 1
else
self.invencible = false
end
end end
------------------------------- -------------------------------
@@ -190,6 +196,7 @@ if DEBUG_FN_NAME then print_dbg("choose_action "..self.mood.." / "..self.moods.s
if self.old_action~=next_action then if self.old_action~=next_action then
self.old_action=next_action self.old_action=next_action
end end
self.action = next_action self.action = next_action
return next_action return next_action
@@ -202,13 +209,11 @@ end
------------------------------- -------------------------------
function imp:controller_input() function imp:controller_input()
if DEBUG_FN_NAME then print_dbg("controller_input") end if DEBUG_FN_NAME then print_dbg("controller_input") end
-- for k,v in pairs(self.actions) do
-- if v==self.action then print("CONTROLLER => "..self.action.." / "..k) end
-- end
if (self.action == self.actions.right or if (self.action == self.actions.right or
self.action == self.actions.left) then self.action == self.actions.left) then
if self.moure == imp.state_normal or self.moure == imp.state_walking then if self.moure == imp.state_normal or self.moure == imp.state_walking then
self:_moure(imp.state_walking, "") self.moure=imp.state_walking
end end
elseif (self.action == self.actions.jump) then elseif (self.action == self.actions.jump) then
if self.moure == imp.state_normal or self.moure == imp.state_walking then if self.moure == imp.state_normal or self.moure == imp.state_walking then
@@ -224,21 +229,6 @@ if DEBUG_FN_NAME then print_dbg("controller_input") end
self:super() self:super()
end end
-- if --(self.moure==imp.state_normal or self.moure==imp.state_walking) and
-- (self.action == self.actions.right or self.action == self.actions.left) then
-- -- self.moure=imp.state_walking
-- self:_moure(imp.state_walking, "state_walking (movement)")
-- elseif (self.moure~=imp.state_falling and self.moure~=imp.state_jumping and
-- self.moure~=imp.state_super) and self.action == self.actions.jump then
-- self:jump()
-- elseif (self.moure==imp.state_normal or self.moure==imp.state_walking) and self.action == self.actions.jumpfwd then
-- self:jump(true)
-- elseif self.action == self.actions.shot then
-- self:shot()
-- elseif (self.moure~=imp.state_falling and self.moure~=imp.state_jumping and
-- self.moure~=imp.state_super) and self.action == self.actions.super then
-- self.moure=imp.state_super
-- end
self.old_action = self.action self.old_action = self.action
self.action = self.actions.no_action self.action = self.actions.no_action
end end
@@ -260,7 +250,7 @@ if DEBUG_FN_NAME then print_dbg("fight") end
self.mood=self.moods.chase self.mood=self.moods.chase
self:pattern_movement() self:pattern_movement()
self:_moure(imp.state_normal,"") self.moure = imp.state_normal
self.stucked = {x=0, y=0, t=0 } self.stucked = {x=0, y=0, t=0 }
end end
@@ -381,18 +371,18 @@ function imp:load_pattern_paths() --OK
} }
self.pattern.path[4] = { self.pattern.path[4] = {
{target=1, actions={{action="jump" , event="target"}}}, {target=1, actions={{action="jump" , event="target"}}},
--{target=5, actions={{action="right", event="target"}}}, {target=5, actions={{action="right", event="target"}}},
--{target=6, actions={{action="right", event="target"}}}, {target=6, actions={{action="right", event="target"}}},
--{target=8, actions={{action="jump" , event="target"}}}, {target=8, actions={{action="jump" , event="target"}}},
} }
self.pattern.path[5] = { self.pattern.path[5] = {
{target=4, actions={{action="left" , event="target"}}}, {target=4, actions={{action="left" , event="target"}}},
{target=6, actions={{action="right", event="target"}}} {target=6, actions={{action="right", event="target"}}}
} }
self.pattern.path[6] = { self.pattern.path[6] = {
--{target=2, actions={{action="jump", event="target"}}}, {target=2, actions={{action="jump", event="target"}}},
--{target=5, actions={{action="left", event="target"}}}, {target=5, actions={{action="left", event="target"}}},
--{target=7, actions={{action="jump", event="target"}}}, {target=7, actions={{action="jump", event="target"}}},
{target=4, actions={{action="left", event="target"}}} {target=4, actions={{action="left", event="target"}}}
} }
self.pattern.path[7] = { self.pattern.path[7] = {
@@ -517,7 +507,9 @@ function imp:next_action()
local next_action = self.actions.no_action local next_action = self.actions.no_action
-- Si el blanc està a tir disparar -- Si el blanc està a tir disparar
if self.timers.shot<=0 and h_collision(self, self.shot_target) then if self.timers.shot<=0 and
h_collision(self, self.shot_target) and
not self.invencible then
next_action = "shot" next_action = "shot"
end end
@@ -568,11 +560,9 @@ if DEBUG_FN_NAME then print_dbg("") end
-- Inicialització de fer el salt -- Inicialització de fer el salt
jumpfwd = jumpfwd or false jumpfwd = jumpfwd or false
self.jump_height = 0 self.jump_height = 0
-- self.moure=imp.state_jumping
self.step=0 self.step=0
self.jumpfwd=jumpfwd self.jumpfwd=jumpfwd
self:_moure(imp.state_jumping,"") self.moure = imp.state_jumping
-- self.action=""
end end
function imp:state_jumping() function imp:state_jumping()
@@ -589,8 +579,7 @@ if DEBUG_FN_NAME then print_dbg("state_jumping") end
self:do_jump() self:do_jump()
else else
-- Canviar a mode caure -- Canviar a mode caure
-- self.moure=imp.state_falling self.moure = imp.state_falling
self:_moure(imp.state_falling,"state_falling (states)")
end end
self.step=self.step+1 self.step=self.step+1
@@ -697,8 +686,7 @@ if DEBUG_FN_NAME then print_dbg("state_falling") end
self.next_frame=imp.falling_next_frame self.next_frame=imp.falling_next_frame
-- Si toca terra canviar el mode -- Si toca terra canviar el mode
if self:land() then if self:land() then
-- self.moure=imp.state_normal self.moure = imp.state_normal
self:_moure(imp.state_normal,"state_normal (states)")
self.jumpfwd = false self.jumpfwd = false
return return
end end
@@ -759,8 +747,7 @@ if DEBUG_FN_NAME then print("state_walking") end
local tile2 = arc_check_tile(x2_check,y_check) local tile2 = arc_check_tile(x2_check,y_check)
if tile1==tiletype.void and tile2==tiletype.void then if tile1==tiletype.void and tile2==tiletype.void then
-- si no hi ha piso, caure -- si no hi ha piso, caure
-- self.moure=imp.state_falling self.moure = imp.state_falling
self:_moure(imp.state_falling, "state_falling (states-walking)")
return return
end end
@@ -812,9 +799,9 @@ function imp:staying_next_frame()
self.frame=28 self.frame=28
end end
function imp:super_next_frame() -- function imp:super_next_frame()
self.frame=11 -- self.frame=11
end -- end
function imp:do_flip( actor ) function imp:do_flip( actor )
actor = actor or self.pattern:target_node() actor = actor or self.pattern:target_node()
@@ -830,9 +817,8 @@ end
function imp:super() function imp:super()
if DEBUG_FN_NAME then print("super()") end if DEBUG_FN_NAME then print("super()") end
self:super_movement() self:super_movement()
-- self.fight_mode = self.fight_modes["super"]
self.invencible = true self.invencible = true
self:_moure(imp.state_super,"") self.moure = imp.state_super
self:reset_timer("super_wait") self:reset_timer("super_wait")
end end
@@ -853,7 +839,7 @@ if DEBUG_FN_NAME then print("state_super") end
end end
if wait == 0 then if wait == 0 then
self:_moure(imp.super_end,"") self.moure = imp.super_end
end end
end end
@@ -861,7 +847,7 @@ function imp:super_end()
self.zoom = 1 self.zoom = 1
self.invencible = false self.invencible = false
self.super_fired = false self.super_fired = false
self:_moure(imp.state_normal,"") self.moure = imp.state_normal
self:reset_timer("mood") self:reset_timer("mood")
self:reset_timer("super") self:reset_timer("super")
self:reset_timer("super_wait") self:reset_timer("super_wait")

View File

@@ -55,6 +55,9 @@ function imp.new(_hab,_x,_y)
zoom = 1, zoom = 1,
super_pal={[13]=13,[14]=14,[15]=15}, super_pal={[13]=13,[14]=14,[15]=15},
super_fired = false, super_fired = false,
can_warp = false,
invencible_time = 0,
death_time=40,
-- --
moure = noop, moure = noop,
draw=imp.draw, draw=imp.draw,
@@ -82,6 +85,7 @@ function imp.new(_hab,_x,_y)
pattern_recovery = imp.pattern_recovery, pattern_recovery = imp.pattern_recovery,
super = imp.super, super = imp.super,
super_movement = imp.super_movement, super_movement = imp.super_movement,
hit = imp.hit,
-- debug -- debug
_moure = imp._moure, _moure = imp._moure,
_pause = false, _pause = false,
@@ -130,7 +134,7 @@ function imp:draw() --OK
end end
function imp:hit() -- OK function imp:hit() -- OK
if DEBUG_FN_NAME then print_dbg("hit") end if not DEBUG_FN_NAME then print_dbg("hit") end
if not self.invencible then if not self.invencible then
self.energia = self.energia -1 self.energia = self.energia -1
if distancia(self, abad)<50 and self.invencible_time<=0 then if distancia(self, abad)<50 and self.invencible_time<=0 then
@@ -145,7 +149,7 @@ if DEBUG_FN_NAME then print_dbg("hit") end
self.energia = 0 self.energia = 0
-- self.enabled = false -- self.enabled = false
print("END BOSS") print("END BOSS")
self.update=imp.update_hit
if self.can_warp then self.warping=true end if self.can_warp then self.warping=true end
self.shrink=1 self.shrink=1
self.angle=0 self.angle=0
@@ -160,6 +164,36 @@ end
function imp:update_hit() function imp:update_hit()
if not self.enabled then return end if not self.enabled then return end
-- Que pasa quan "mor" -- Que pasa quan "mor"
local step_time = self.death_time
if self.can_warp then
step_time = self.death_time/3; -- warp, wait, appear
end
self.wait=self.wait+1
if self.wait>=6 then
self.wait=0
self.step=self.step+1
if self.can_warp then
actor_warp_update(self)
else
if self.step<self.death_time then
if self.step%2==0 then
-- self.frame=21
self.frame=self.anim[#self.anim]
else
self.frame=-1
end
elseif self.step>=self.death_time then
-- self.frame=19
self.frame=self.anim[1]
self.step=0
self.wait=0
self.update=caco.update_normal
self.dying = false
end
end
end
end end
function imp:update_normal() function imp:update_normal()
-- print("") -- print("")
@@ -191,7 +225,9 @@ function imp:update_normal()
-- moviment -- moviment
self:controller_input() self:controller_input()
self:moure() self:moure()
-- Que no conte si està en modo Super -- Que no conte si està en modo Super
if self.move_type ~= self.move_types.super then
if self.stucked.x == self.x and self.stucked.y == self.y then if self.stucked.x == self.x and self.stucked.y == self.y then
self.stucked.t = self.stucked.t + 1 self.stucked.t = self.stucked.t + 1
else else
@@ -199,6 +235,8 @@ function imp:update_normal()
self.stucked.y = self.y self.stucked.y = self.y
self.stucked.t = 0 self.stucked.t = 0
end end
end
-- Logica per a selecció de frame -- Logica per a selecció de frame
self:next_frame() self:next_frame()
end end