[WIP] Treballant en el jefe. Tram final
This commit is contained in:
@@ -38,13 +38,14 @@ function fireball.draw()
|
||||
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,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
|
||||
|
||||
function fireball.update()
|
||||
if fireball.power==2 and fireball.power>fireball.size then
|
||||
fireball.wait = fireball.wait + 1
|
||||
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
|
||||
fireball.step_length_x = -1
|
||||
else
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
function imp:_moure( foo, name )
|
||||
-- name = name or "anonymous"
|
||||
-- if not foo then
|
||||
-- print_dbg(name.." not found")
|
||||
-- else
|
||||
-- print_dbg(name)
|
||||
-- end
|
||||
self.moure = foo
|
||||
end
|
||||
-- function imp:_moure( foo, name )
|
||||
-- -- name = name or "anonymous"
|
||||
-- -- if not foo then
|
||||
-- -- print_dbg(name.." not found")
|
||||
-- -- else
|
||||
-- -- print_dbg(name)
|
||||
-- -- end
|
||||
-- self.moure = foo
|
||||
-- end
|
||||
|
||||
function noop ()
|
||||
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
|
||||
end
|
||||
end
|
||||
|
||||
if self.invencible and self.invencible_time >0 then
|
||||
self.invencible_time = self.invencible_time - 1
|
||||
else
|
||||
self.invencible = false
|
||||
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
|
||||
self.old_action=next_action
|
||||
end
|
||||
|
||||
self.action = next_action
|
||||
|
||||
return next_action
|
||||
@@ -202,13 +209,11 @@ end
|
||||
-------------------------------
|
||||
function imp:controller_input()
|
||||
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
|
||||
self.action == self.actions.left) 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
|
||||
elseif (self.action == self.actions.jump) 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()
|
||||
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.action = self.actions.no_action
|
||||
end
|
||||
@@ -260,7 +250,7 @@ if DEBUG_FN_NAME then print_dbg("fight") end
|
||||
|
||||
self.mood=self.moods.chase
|
||||
self:pattern_movement()
|
||||
self:_moure(imp.state_normal,"")
|
||||
self.moure = imp.state_normal
|
||||
self.stucked = {x=0, y=0, t=0 }
|
||||
end
|
||||
|
||||
@@ -381,18 +371,18 @@ function imp:load_pattern_paths() --OK
|
||||
}
|
||||
self.pattern.path[4] = {
|
||||
{target=1, actions={{action="jump" , event="target"}}},
|
||||
--{target=5, actions={{action="right", event="target"}}},
|
||||
--{target=6, actions={{action="right", event="target"}}},
|
||||
--{target=8, actions={{action="jump" , event="target"}}},
|
||||
{target=5, actions={{action="right", event="target"}}},
|
||||
{target=6, actions={{action="right", event="target"}}},
|
||||
{target=8, actions={{action="jump" , event="target"}}},
|
||||
}
|
||||
self.pattern.path[5] = {
|
||||
{target=4, actions={{action="left" , event="target"}}},
|
||||
{target=6, actions={{action="right", event="target"}}}
|
||||
}
|
||||
self.pattern.path[6] = {
|
||||
--{target=2, actions={{action="jump", event="target"}}},
|
||||
--{target=5, actions={{action="left", event="target"}}},
|
||||
--{target=7, actions={{action="jump", event="target"}}},
|
||||
{target=2, actions={{action="jump", event="target"}}},
|
||||
{target=5, actions={{action="left", event="target"}}},
|
||||
{target=7, actions={{action="jump", event="target"}}},
|
||||
{target=4, actions={{action="left", event="target"}}}
|
||||
}
|
||||
self.pattern.path[7] = {
|
||||
@@ -517,7 +507,9 @@ function imp:next_action()
|
||||
local next_action = self.actions.no_action
|
||||
|
||||
-- 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"
|
||||
end
|
||||
|
||||
@@ -568,11 +560,9 @@ if DEBUG_FN_NAME then print_dbg("") end
|
||||
-- Inicialització de fer el salt
|
||||
jumpfwd = jumpfwd or false
|
||||
self.jump_height = 0
|
||||
-- self.moure=imp.state_jumping
|
||||
self.step=0
|
||||
self.jumpfwd=jumpfwd
|
||||
self:_moure(imp.state_jumping,"")
|
||||
-- self.action=""
|
||||
self.moure = imp.state_jumping
|
||||
end
|
||||
|
||||
function imp:state_jumping()
|
||||
@@ -589,8 +579,7 @@ if DEBUG_FN_NAME then print_dbg("state_jumping") end
|
||||
self:do_jump()
|
||||
else
|
||||
-- Canviar a mode caure
|
||||
-- self.moure=imp.state_falling
|
||||
self:_moure(imp.state_falling,"state_falling (states)")
|
||||
self.moure = imp.state_falling
|
||||
end
|
||||
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
|
||||
-- Si toca terra canviar el mode
|
||||
if self:land() then
|
||||
-- self.moure=imp.state_normal
|
||||
self:_moure(imp.state_normal,"state_normal (states)")
|
||||
self.moure = imp.state_normal
|
||||
self.jumpfwd = false
|
||||
return
|
||||
end
|
||||
@@ -759,8 +747,7 @@ if DEBUG_FN_NAME then print("state_walking") end
|
||||
local tile2 = arc_check_tile(x2_check,y_check)
|
||||
if tile1==tiletype.void and tile2==tiletype.void then
|
||||
-- si no hi ha piso, caure
|
||||
-- self.moure=imp.state_falling
|
||||
self:_moure(imp.state_falling, "state_falling (states-walking)")
|
||||
self.moure = imp.state_falling
|
||||
return
|
||||
end
|
||||
|
||||
@@ -812,9 +799,9 @@ function imp:staying_next_frame()
|
||||
self.frame=28
|
||||
end
|
||||
|
||||
function imp:super_next_frame()
|
||||
self.frame=11
|
||||
end
|
||||
-- function imp:super_next_frame()
|
||||
-- self.frame=11
|
||||
-- end
|
||||
|
||||
function imp:do_flip( actor )
|
||||
actor = actor or self.pattern:target_node()
|
||||
@@ -830,9 +817,8 @@ end
|
||||
function imp:super()
|
||||
if DEBUG_FN_NAME then print("super()") end
|
||||
self:super_movement()
|
||||
-- self.fight_mode = self.fight_modes["super"]
|
||||
self.invencible = true
|
||||
self:_moure(imp.state_super,"")
|
||||
self.moure = imp.state_super
|
||||
self:reset_timer("super_wait")
|
||||
end
|
||||
|
||||
@@ -853,7 +839,7 @@ if DEBUG_FN_NAME then print("state_super") end
|
||||
end
|
||||
|
||||
if wait == 0 then
|
||||
self:_moure(imp.super_end,"")
|
||||
self.moure = imp.super_end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -861,7 +847,7 @@ function imp:super_end()
|
||||
self.zoom = 1
|
||||
self.invencible = false
|
||||
self.super_fired = false
|
||||
self:_moure(imp.state_normal,"")
|
||||
self.moure = imp.state_normal
|
||||
self:reset_timer("mood")
|
||||
self:reset_timer("super")
|
||||
self:reset_timer("super_wait")
|
||||
|
||||
@@ -55,6 +55,9 @@ function imp.new(_hab,_x,_y)
|
||||
zoom = 1,
|
||||
super_pal={[13]=13,[14]=14,[15]=15},
|
||||
super_fired = false,
|
||||
can_warp = false,
|
||||
invencible_time = 0,
|
||||
death_time=40,
|
||||
--
|
||||
moure = noop,
|
||||
draw=imp.draw,
|
||||
@@ -82,6 +85,7 @@ function imp.new(_hab,_x,_y)
|
||||
pattern_recovery = imp.pattern_recovery,
|
||||
super = imp.super,
|
||||
super_movement = imp.super_movement,
|
||||
hit = imp.hit,
|
||||
-- debug
|
||||
_moure = imp._moure,
|
||||
_pause = false,
|
||||
@@ -130,7 +134,7 @@ function imp:draw() --OK
|
||||
end
|
||||
|
||||
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
|
||||
self.energia = self.energia -1
|
||||
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.enabled = false
|
||||
print("END BOSS")
|
||||
|
||||
self.update=imp.update_hit
|
||||
if self.can_warp then self.warping=true end
|
||||
self.shrink=1
|
||||
self.angle=0
|
||||
@@ -160,6 +164,36 @@ end
|
||||
function imp:update_hit()
|
||||
if not self.enabled then return end
|
||||
-- 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
|
||||
function imp:update_normal()
|
||||
-- print("")
|
||||
@@ -191,14 +225,18 @@ function imp:update_normal()
|
||||
-- moviment
|
||||
self:controller_input()
|
||||
self:moure()
|
||||
|
||||
-- Que no conte si està en modo Super
|
||||
if self.stucked.x == self.x and self.stucked.y == self.y then
|
||||
self.stucked.t = self.stucked.t + 1
|
||||
else
|
||||
self.stucked.x = self.x
|
||||
self.stucked.y = self.y
|
||||
self.stucked.t = 0
|
||||
if self.move_type ~= self.move_types.super then
|
||||
if self.stucked.x == self.x and self.stucked.y == self.y then
|
||||
self.stucked.t = self.stucked.t + 1
|
||||
else
|
||||
self.stucked.x = self.x
|
||||
self.stucked.y = self.y
|
||||
self.stucked.t = 0
|
||||
end
|
||||
end
|
||||
|
||||
-- Logica per a selecció de frame
|
||||
self:next_frame()
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user