[WIP] El Abad ja arounda mes o menys be. Afegida capacitat per a entrar dins de tiles que el dibuix es només la meitat d'alt

This commit is contained in:
2026-03-22 13:31:56 +01:00
parent 57bd5bef4e
commit 5314f13d81
3 changed files with 116 additions and 34 deletions

View File

@@ -1,9 +1,6 @@
-- TO DO: Afegir un contador per a saber quan de temps está parat el abad per a traure al Imp
local arcade_config = require("arcade_config")
o2aX = arcade_config.org2arc_escala
cxr = arcade_config.character_per_row-1
cxr2 = arcade_config.character_per_row_base2
-- local arcade_config = require("arcade_config")
cw = arcade_config.character_width
ch = arcade_config.character_height
@@ -53,6 +50,8 @@ function abad_init()
vmove_space=1,
max_jump_height=24,
jump_height=0,
jump_in_half_block=0,
jump_in_half_block_used = false,
max_shoot_cooldown=24,
shoot_cooldown=25,
anim={0,1,0,2},
@@ -147,9 +146,90 @@ function abad_shot_cacau ()
cacau.init(abad.hab,abad.x+8,abad.y+8,abad.flip)
end
function abad_land ()
-- abad.x
-- abad.y
function abad_jump()
local vspace = abad.vmove_space
-- Els dos punts de dalt de l'abad
local x1_check = abad.x+abad.bb.x
local x2_check = abad.x+abad.bb.x+abad.bb.w
local y_check = abad.y-vspace
-- Comprovar on està pegant
local tile1_hit_type= arc_check_tile(x1_check, y_check )
local tile2_hit_type= arc_check_tile(x2_check, y_check)
local not_block_tile = tile1_hit_type ~= tiletype.block and tile2_hit_type ~= tiletype.block
local switch_tile = tile1_hit_type == tiletype.switch or tile2_hit_type == tiletype.switch
-- print("JUMP > "..x1_check..", "..x2_check..", "..y_check)
-- print("T1= "..tile1_hit_type.." / T2= "..tile2_hit_type)
-- local msg = "BLOCK TILE HITTED"
-- if not_block_tile then msg="not block" end
-- print(msg)
-- Fer l'acció que correspon
if not_block_tile then
if switch_tile then
-- Executar el switch
switches.start(abad.hab,1+xx+yy*12)
else
abad.y=abad.y-vspace
end
else
local tile1_hit = arc_get_tile(x1_check, y_check )
local tile2_hit = arc_get_tile(x2_check, y_check)
local half_block1 = mapa_is_half_block_tile(tile1_hit)
local half_block2 = mapa_is_half_block_tile(tile2_hit)
local full_block1 = tile1_hit_type == tiletype.block and not half_block1
local full_block2 = tile2_hit_type == tiletype.block and not half_block2
local full_block = full_block1 and full_block2
local half_block = half_block1 or half_block2
-- print("BLOCK TILE")
-- msg = tile1_hit.." "..tile2_hit.." >> "
-- if half_block1 then msg= msg.."half_block1 " end
-- if half_block2 then msg= msg.."half_block2 " end
-- if full_block1 then msg= msg.."full_block1 " end
-- if full_block2 then msg= msg.."full_block2 " end
-- if full_block then msg= msg.."full_block " end
-- if half_block then msg= msg.."half_block " end
-- if abad.jump_in_half_block_used then msg= msg.."jump_in_half_block_used " end
-- print(msg)
-- Si ninguno dels tiles tocats es un block complet
-- i almenys un dels tiles tocats es mig tile
-- permetre continuar en el salt
if not full_block and half_block then
if abad.jump_in_half_block==0 and not abad.jump_in_half_block_used then
abad.jump_in_half_block = arcade_config.tiles_height>>1
end
if abad.jump_in_half_block>0 then
abad.y=abad.y-vspace
abad.jump_in_half_block = abad.jump_in_half_block-1
end
end
end
abad.jump_height = abad.jump_height+1
abad.jump_in_half_block_used = true
end
function abad_land ()
-- Els dos punts de baix de l'abad
local x1_check = abad.x+abad.bb.x
local x2_check = abad.x+abad.bb.x+abad.bb.w
local y_check = abad.y+abad.bb.h
-- Comprovar on està aterrant
local tile1_hit= arc_check_tile(x1_check, y_check )
local tile2_hit= arc_check_tile(x2_check, y_check)
local floor_tile = tile1_hit>=tiletype.half or tile2_hit>=tiletype.half
-- Encara que siga un tile de piso s'ha de comprovar que
-- la y es un múltiple de l'alt dels tiles
local over_tile = (y_check & 0xF) == 0
local can_land = floor_tile and over_tile
if can_land then
abad.jump_in_half_block_used = false
abad.jump_height = 0
end
return can_land
end
function abad_advance()
@@ -295,7 +375,6 @@ function abad_state_walking()
end
function abad_state_jumping()
local vspace = abad.vmove_space
local step_length = abad.step_length
abad.frame=3
abad.wait=abad.wait+1
@@ -303,23 +382,13 @@ function abad_state_jumping()
abad.wait=0
if abad.jump_height<abad.max_jump_height then
if arc_check_tile(abad.x+step_length,abad.y-vspace)~=tiletype.block then
if arc_check_tile(abad.x+abad.bb.x+abad.bb.w,abad.y-vspace)~=tiletype.block then
if arc_check_tile(abad.x+abad.bb.x,abad.y-vspace)==tiletype.switch then
-- Executar el switch
switches.start(abad.hab,1+xx+yy*12)
else
abad.jump_height = abad.jump_height+1
end
end
end
abad_jump()
else
-- Canviar a mode caure
abad.update=abad_state_falling
abad.jump=sound.play(audio_abad_fall)
end
abad.step=abad.step+1
abad.y=abad.y-vspace
if abad.jumpfwd then abad_advance() end
@@ -349,16 +418,8 @@ function abad_state_falling()
-- abad.y=0
-- end
end
local x_check = abad.x+abad.bb.x
local y_check = abad.y+abad.bb.h
local curr_tile = arc_check_tile(x_check,y_check)
local next_tile = arc_check_tile(x_check+abad.bb.w,y_check)
local check_floor_curr_tile = curr_tile>=tiletype.half
local check_floor_next_tile = next_tile>=tiletype.half
if check_floor_curr_tile or check_floor_next_tile then
if abad_land() then
abad.update=abad_state_normal
return
end