diff --git a/data/abad.lua b/data/abad.lua index 430782e..978de63 100644 --- a/data/abad.lua +++ b/data/abad.lua @@ -311,6 +311,7 @@ end function abad_in_stairs(next_x, next_y) next_x = next_x or 0 next_y = next_y or 0 + local result = false -- local x1_check = abad.x+abad.bb.x+next_x -- local x2_check = abad.x+abad.bb.x+abad.bb.w+next_x @@ -332,10 +333,12 @@ function abad_in_stairs(next_x, next_y) if arc_check_tile(x1_check, y1_check)==tiletype.stair or arc_check_tile(x1_check, y2_check)==tiletype.stair then - return true + result = true end - return false + if result then print("IN STAIRS "..next_x.." "..next_y) else print("-") end + + return result end function abad_in_floor(next_x, next_y) @@ -394,6 +397,14 @@ function abad_advance() abad.hab = hab end +function abad_move_down() + if abad_in_stairs() then + abad.update=abad_state_stairs + else + abad.update=abad_state_crouch + end +end + -- Controlador principal de l'abad function abad_state_normal() abad.frame=0 @@ -423,11 +434,7 @@ function abad_state_normal() if controller:check("up") and abad_in_stairs() then abad.update=abad_state_stairs elseif controller:check("down") then - if abad_in_stairs() then - abad.update=abad_state_stairs - else - abad.update=abad_state_crouch - end + abad_move_down() elseif controller:check("right") then abad.update=abad_state_walking abad.flip=false @@ -512,7 +519,7 @@ function abad_state_walking() abad_do_jump(true); -- jumping forward return elseif controller:check("down") then - abad.update=abad_state_crouch + abad_move_down() elseif controller:check("shoot") then abad_shot_cacau() end