134 lines
3.6 KiB
Lua
134 lines
3.6 KiB
Lua
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
|
|
cw = arcade_config.character_width
|
|
ch = arcade_config.character_height
|
|
|
|
-- 4, 3
|
|
|
|
imp={hab=75,
|
|
x=24,
|
|
y=24,
|
|
w=32,
|
|
h=32,
|
|
flip=true,
|
|
enabled=false,
|
|
counter=500,
|
|
frame=28,
|
|
wait=0,
|
|
step=0,
|
|
anim={28,29,28,30},
|
|
bb={x=4,y=0,w=16,h=32},
|
|
scene_intro=false,
|
|
scene_object=false,
|
|
mode="stop"}
|
|
|
|
function imp.reset()
|
|
imp.hit=imp.hit
|
|
imp.update=imp.update
|
|
imp.draw=imp.draw
|
|
imp.hab=abad.hab
|
|
imp.enabled=false
|
|
imp.counter=500
|
|
end
|
|
|
|
function imp.init()
|
|
-- imp.enabled=false
|
|
-- imp.hit=imp.hit
|
|
-- imp.update=imp.update
|
|
-- imp.draw=imp.draw
|
|
-- imp.hab=abad.hab
|
|
-- if abad.x<40 then
|
|
-- if check_tile(imp.hab,92,38)<tiletype.half and
|
|
-- check_tile(imp.hab,84,38)<tiletype.half and
|
|
-- check_tile(imp.hab,92,30)<tiletype.half and
|
|
-- check_tile(imp.hab,84,30)<tiletype.half and
|
|
-- check_tile(imp.hab,92,46)>=tiletype.half then
|
|
-- imp.enabled=true
|
|
-- imp.flip=true
|
|
-- imp.x=92
|
|
-- else
|
|
-- imp.reset()
|
|
-- end
|
|
-- else
|
|
-- if check_tile(imp.hab,0,38)<tiletype.half and
|
|
-- check_tile(imp.hab,8,38)<tiletype.half and
|
|
-- check_tile(imp.hab,0,30)<tiletype.half and
|
|
-- check_tile(imp.hab,0,30)<tiletype.half and
|
|
-- check_tile(imp.hab,0,46)>=tiletype.half then
|
|
-- imp.enabled=true
|
|
-- imp.flip=false
|
|
-- imp.x=-12
|
|
-- else
|
|
-- imp.reset()
|
|
-- end
|
|
-- end
|
|
imp.hab=55
|
|
local world_x, world_y = coords.room_to_world(55,4,3)
|
|
imp.x=world_x
|
|
imp.y=world_y
|
|
imp.flip = true
|
|
end
|
|
|
|
function imp.draw()
|
|
-- if imp.enabled then
|
|
-- -- draw.surf((imp.frame&7)*16,(imp.frame>>3)*16,16,16,imp.x,imp.y,16,16,imp.flip)
|
|
-- draw.surf((imp.frame&7)*cw,(imp.frame>>cxr2)*ch,cw,ch,imp.x*o2aX,imp.y*o2aX,cw,ch,imp.flip)
|
|
-- end
|
|
local scr_x, scr_y = viewp:screen_coords( imp.x, imp.y )
|
|
draw.surf((imp.frame&7)*imp.w, (imp.frame>>cxr2)*imp.h, imp.w, imp.h, scr_x, scr_y, imp.w, imp.h, imp.flip)
|
|
end
|
|
|
|
function imp.hit()
|
|
end
|
|
|
|
function imp.update()
|
|
if mode=="chase" then
|
|
if abad.x<imp.x then
|
|
imp.x=imp.x-1
|
|
elseif abad.x>imp.x then
|
|
imp.x=imp.x+1
|
|
end
|
|
end
|
|
-- imp.wait=imp.wait+1
|
|
--
|
|
-- if imp.wait==6 then
|
|
-- imp.wait=0
|
|
-- if not imp.enabled then
|
|
-- imp.counter=imp.counter-1
|
|
-- local r = math.random(0,imp.counter-1)
|
|
-- --print(r)
|
|
-- if imp.counter==1 or r==1 then
|
|
-- imp.init()
|
|
-- end
|
|
-- return
|
|
-- end
|
|
--
|
|
-- imp.step=(imp.step+1)%4
|
|
-- imp.frame=imp.anim[imp.step+1]
|
|
--
|
|
-- if imp.flip then
|
|
-- imp.x=imp.x-2
|
|
-- if imp.x==78 then
|
|
-- fireball.init(imp.hab,imp.x+8,imp.y+4,imp.flip)
|
|
-- sound.play(audio_hit)
|
|
-- imp.flip=not imp.flip
|
|
-- elseif imp.x==-12 then
|
|
-- imp.reset()
|
|
-- end
|
|
-- else
|
|
-- imp.x=imp.x+2
|
|
-- if imp.x==4 then
|
|
-- fireball.init(imp.hab,imp.x+8,imp.y+4,imp.flip)
|
|
-- sound.play(audio_hit)
|
|
-- imp.flip=not imp.flip
|
|
-- elseif imp.x==92 then
|
|
-- imp.reset()
|
|
-- end
|
|
-- end
|
|
--
|
|
-- end
|
|
end
|
|
|