Files
cacaus-arcade/data/fireball.lua

62 lines
1.6 KiB
Lua

fireball={
hab=-1,
x=0, y=0,
w=6, h=6,
wait=0,
flip=false,
step_length=3,
bb={x=0,y=0,w=4,h=4}
}
function fireball.init(_hab,_x,_y,_flip, _off_x, _off_y)
local world_x, world_y = coords.room_to_world(_hab,_x,_y)
if fireball.hab ~= -1 then return end
_off_x = _off_x or 0
_off_y = _off_y or 0
fireball.hab=_hab
fireball.x= world_x+_off_x
fireball.y= world_y+_off_y
fireball.flip=_flip
end
function fireball.draw()
if fireball.hab == -1 then return end
local scr_x, scr_y = viewp:screen_coords( fireball.x, fireball.y )
draw.circf(scr_x,scr_y,8,16)
draw.circf(scr_x,scr_y,6,3)
draw.circf(scr_x,scr_y,2,8)
end
function fireball.update()
if fireball.hab == -1 then return end
fireball.wait=fireball.wait+1
--if fireball.wait==3 then
fireball.wait=0
--if viewp:inside(fireball.x, fireball.y, fireball.w, fireball.h)==false then
-- fireball.hab=-1
-- return
--end
if arc_check_tile(fireball.x,fireball.y)<tiletype.block then
if fireball.flip then
fireball.x=fireball.x-fireball.step_length
else
fireball.x=fireball.x+fireball.step_length
end
else
fireball.hab=-1
return
end
if viewp:inside(fireball.x, fireball.y, fireball.w, fireball.h) then
if collision(fireball,abad) and abad.update~=abad_state_crouch then
fireball.hab=-1
abad_hurt(1)
end
end
--end
end