[FIX] Incidencia #3 parcialment resolta ('tembleque')
[NEW] La manera de pujar y baixar les escales ha canviat
This commit is contained in:
117
data/abad.lua
117
data/abad.lua
@@ -44,6 +44,7 @@ function abad_init()
|
|||||||
step=0,
|
step=0,
|
||||||
mustep=1,
|
mustep=1,
|
||||||
stairs_flip=false,
|
stairs_flip=false,
|
||||||
|
stairs_moves=0, --contador de moviments dins de les escales
|
||||||
draw=abad.draw,
|
draw=abad.draw,
|
||||||
hurting=0,
|
hurting=0,
|
||||||
update=nil,
|
update=nil,
|
||||||
@@ -99,13 +100,22 @@ function abad:draw()
|
|||||||
local flip = abad.flip
|
local flip = abad.flip
|
||||||
local x, y = viewp:screen_coords(self.x, self.y)
|
local x, y = viewp:screen_coords(self.x, self.y)
|
||||||
if abad.update==abad_state_stairs then
|
if abad.update==abad_state_stairs then
|
||||||
flip=abad.stairs_flip
|
-- flip=abad.stairs_flip
|
||||||
-- flip=(((abad.x>>1)+(abad.y>>1))%2)==0
|
-- -- flip=(((abad.x>>1)+(abad.y>>1))%2)==0
|
||||||
if ((abad.x+abad.y)%12)==0 then abad.stairs_flip=not abad.stairs_flip end
|
if math.abs(abad.stairs_moves-(abad.x+abad.y))>12 then
|
||||||
local msg = "-- "..abad.x.." "..abad.y
|
abad.stairs_moves = abad.x+abad.y
|
||||||
if flip then msg = "FLIP"..abad.x.." "..abad.y end
|
abad.flip = not abad.flip
|
||||||
-- msg_print(0,35,msg,true)
|
|
||||||
end
|
end
|
||||||
|
flip = abad.flip
|
||||||
|
-- if ((abad.x+abad.y)%12)==0 then
|
||||||
|
-- abad.stairs_flip=not abad.stairs_flip
|
||||||
|
-- end
|
||||||
|
|
||||||
|
-- local msg = "-- "..abad.x.." "..abad.y
|
||||||
|
-- if flip then msg = "FLIP"..abad.x.." "..abad.y end
|
||||||
|
-- -- msg_print(0,35,msg,true)
|
||||||
|
end
|
||||||
|
|
||||||
if (abad.respawning==0) or (math.floor(abad.respawning/15)%2==0) then
|
if (abad.respawning==0) or (math.floor(abad.respawning/15)%2==0) then
|
||||||
draw.surf(abad.frame*abad.w,0,abad.w,abad.h,x,y,abad.w,abad.h,flip)
|
draw.surf(abad.frame*abad.w,0,abad.w,abad.h,x,y,abad.w,abad.h,flip)
|
||||||
-- caminant, parat, disparant o saltant
|
-- caminant, parat, disparant o saltant
|
||||||
@@ -139,7 +149,7 @@ function abad_heal(howmuch)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function abad_hurt(howmuch)
|
function abad_hurt(howmuch)
|
||||||
-- howmuch = 0
|
howmuch = 0
|
||||||
if abad.hurting == 0 and abad.respawning==0 then
|
if abad.hurting == 0 and abad.respawning==0 then
|
||||||
sound.play(audio_abad_hit)
|
sound.play(audio_abad_hit)
|
||||||
abad.energia=abad.energia-howmuch
|
abad.energia=abad.energia-howmuch
|
||||||
@@ -298,6 +308,38 @@ function abad_land ()
|
|||||||
return can_land
|
return can_land
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function abad_in_stairs(next_x, next_y)
|
||||||
|
next_x = next_x or 0
|
||||||
|
next_y = next_y or 0
|
||||||
|
local x1_check = abad.x+abad.bb.x+next_x
|
||||||
|
local x2_check = abad.x+abad.bb.x+abad.bb.w+next_x
|
||||||
|
local y1_check = abad.y+next_y
|
||||||
|
local y2_check = abad.y+abad.bb.h+next_y
|
||||||
|
|
||||||
|
if arc_check_tile(x1_check, y1_check)==tiletype.stair or
|
||||||
|
arc_check_tile(x2_check, y1_check)==tiletype.stair or
|
||||||
|
arc_check_tile(x1_check, y2_check)==tiletype.stair or
|
||||||
|
arc_check_tile(x2_check, y2_check)==tiletype.stair
|
||||||
|
then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
function abad_in_floor(next_x, next_y)
|
||||||
|
local x1_check = abad.x+abad.bb.x+next_x
|
||||||
|
local x2_check = abad.x+abad.bb.x+abad.bb.w+next_x
|
||||||
|
local y2_check = abad.y+abad.bb.h+next_y
|
||||||
|
if arc_check_tile(x1_check, y2_check)==tiletype.block or
|
||||||
|
arc_check_tile(x2_check, y2_check)==tiletype.block
|
||||||
|
then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
function abad_advance()
|
function abad_advance()
|
||||||
local step_length=abad.step_length; --lo que avança l'abad cada pas
|
local step_length=abad.step_length; --lo que avança l'abad cada pas
|
||||||
local limit=tiletype.block
|
local limit=tiletype.block
|
||||||
@@ -315,12 +357,25 @@ function abad_advance()
|
|||||||
abad.x=abad.x+step_length
|
abad.x=abad.x+step_length
|
||||||
end
|
end
|
||||||
|
|
||||||
if arc_check_tile(x_check,y_check)==tiletype.stair then
|
-- if arc_check_tile(x_check,y_check)==tiletype.stair then
|
||||||
abad.update=abad_state_stairs
|
-- print("STAIRS "..math.random(50))
|
||||||
elseif abad.update==abad_state_stairs then
|
-- if abad.update~=abad_state_stairs and controller:check("up")
|
||||||
|
-- then
|
||||||
|
-- print("UPDATE STAIRS")
|
||||||
|
-- abad.update=abad_state_stairs
|
||||||
|
-- end
|
||||||
|
-- elseif abad.update==abad_state_stairs then
|
||||||
|
-- abad.update=abad_state_normal
|
||||||
|
-- abad.frame=0
|
||||||
|
-- end
|
||||||
|
|
||||||
|
if not abad_in_stairs() and
|
||||||
|
abad.update==abad_state_stairs
|
||||||
|
then
|
||||||
abad.update=abad_state_normal
|
abad.update=abad_state_normal
|
||||||
abad.frame=0
|
abad.frame=0
|
||||||
end
|
end
|
||||||
|
|
||||||
local hab,xx, yy = coords.world_to_tile(abad.x, abad.y)
|
local hab,xx, yy = coords.world_to_tile(abad.x, abad.y)
|
||||||
abad.hab = hab
|
abad.hab = hab
|
||||||
end
|
end
|
||||||
@@ -354,13 +409,19 @@ function abad_state_normal()
|
|||||||
if controller:check("right") then
|
if controller:check("right") then
|
||||||
abad.update=abad_state_walking
|
abad.update=abad_state_walking
|
||||||
abad.flip=false
|
abad.flip=false
|
||||||
|
elseif controller:check("up") and abad_in_stairs() then
|
||||||
|
abad.update=abad_state_stairs
|
||||||
elseif controller:check("left") then
|
elseif controller:check("left") then
|
||||||
abad.update=abad_state_walking
|
abad.update=abad_state_walking
|
||||||
abad.flip=true
|
abad.flip=true
|
||||||
elseif controller:check("jump") then
|
elseif controller:check("jump") then
|
||||||
abad_do_jump()
|
abad_do_jump()
|
||||||
elseif controller:check("down") then
|
elseif controller:check("down") then
|
||||||
|
if abad_in_stairs() then
|
||||||
|
abad.update=abad_state_stairs
|
||||||
|
else
|
||||||
abad.update=abad_state_crouch
|
abad.update=abad_state_crouch
|
||||||
|
end
|
||||||
--elseif btn(KEY_Z) then
|
--elseif btn(KEY_Z) then
|
||||||
-- abad.respawning=240
|
-- abad.respawning=240
|
||||||
elseif controller:check("shoot") then
|
elseif controller:check("shoot") then
|
||||||
@@ -520,32 +581,46 @@ end
|
|||||||
function abad_state_stairs()
|
function abad_state_stairs()
|
||||||
abad.frame=4
|
abad.frame=4
|
||||||
abad.wait=abad.wait+1
|
abad.wait=abad.wait+1
|
||||||
|
local moved = false
|
||||||
|
|
||||||
local x1_check = abad.x+abad.bb.x
|
--local x1_check = abad.x+abad.bb.x
|
||||||
local x2_check = abad.x+abad.bb.x+abad.bb.w-1
|
--local x2_check = abad.x+abad.bb.x+abad.bb.w-1
|
||||||
local y_check = abad.y+abad.bb.h-1
|
--local y_check = abad.y+abad.bb.h
|
||||||
|
|
||||||
if controller:check("right") then
|
if controller:check("right") then
|
||||||
abad.flip=false
|
abad.flip=false
|
||||||
abad_advance()
|
abad_advance()
|
||||||
if abad.wait==6 then sound.play(audio_low) end
|
moved = true
|
||||||
elseif controller:check("left") then
|
elseif controller:check("left") then
|
||||||
abad.flip=true
|
abad.flip=true
|
||||||
abad_advance()
|
abad_advance()
|
||||||
if abad.wait==6 then sound.play(audio_low) end
|
moved = true
|
||||||
elseif controller:check("up") then
|
elseif controller:check("up") then
|
||||||
if arc_check_tile(x1_check,y_check)==tiletype.stair and
|
--y_check = y_check - 1
|
||||||
arc_check_tile(x2_check,y_check)==tiletype.stair then
|
--if arc_check_tile(x1_check,y_check)==tiletype.stair and
|
||||||
|
-- arc_check_tile(x2_check,y_check)==tiletype.stair then
|
||||||
|
-- abad.y=abad.y-1
|
||||||
|
-- if abad.wait==6 then sound.play(audio_low) end
|
||||||
|
--end
|
||||||
|
if abad_in_stairs(0,-1) then
|
||||||
abad.y=abad.y-1
|
abad.y=abad.y-1
|
||||||
if abad.wait==6 then sound.play(audio_low) end
|
moved = true
|
||||||
end
|
end
|
||||||
elseif controller:check("down") then
|
elseif controller:check("down") then
|
||||||
if arc_check_tile(x1_check,y_check)==tiletype.stair and
|
-- y_check = y_check + 1
|
||||||
arc_check_tile(x2_check,y_check)==tiletype.stair then
|
-- if arc_check_tile(x1_check,y_check)==tiletype.stair and
|
||||||
|
-- arc_check_tile(x2_check,y_check)==tiletype.stair then
|
||||||
|
-- abad.y=abad.y+1
|
||||||
|
-- if abad.wait==6 then sound.play(audio_low) end
|
||||||
|
-- end
|
||||||
|
if abad_in_stairs(0,1) and not abad_in_floor(0,0) then
|
||||||
abad.y=abad.y+1
|
abad.y=abad.y+1
|
||||||
if abad.wait==6 then sound.play(audio_low) end
|
moved = true
|
||||||
|
else
|
||||||
|
--abad.update=abad_state_normal
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
if moved and abad.wait==6 then sound.play(audio_low) end
|
||||||
|
|
||||||
if abad.wait==6 then abad.wait=0 end
|
if abad.wait==6 then abad.wait=0 end
|
||||||
end
|
end
|
||||||
@@ -27,7 +27,7 @@ require "batman"
|
|||||||
require "health_potion"
|
require "health_potion"
|
||||||
require "tiles_layer2"
|
require "tiles_layer2"
|
||||||
|
|
||||||
local DEBUG = true
|
local DEBUG = false
|
||||||
|
|
||||||
local tile_w = arcade_config.tiles_width
|
local tile_w = arcade_config.tiles_width
|
||||||
local tile_h = arcade_config.tiles_height
|
local tile_h = arcade_config.tiles_height
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ function trigger:draw()
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- debug rect
|
-- debug rect
|
||||||
-- draw.rect(scr_x,scr_y,self.bb.w,self.bb.h,3)
|
draw.rect(scr_x,scr_y,self.bb.w,self.bb.h,3)
|
||||||
end
|
end
|
||||||
|
|
||||||
--function trigger:do_touched()
|
--function trigger:do_touched()
|
||||||
|
|||||||
Reference in New Issue
Block a user