- Imp and fireball implemented

This commit is contained in:
2022-10-28 11:14:48 +02:00
parent 5587c3bd72
commit c1367b3c75
5 changed files with 156 additions and 2 deletions

50
fireball.lua Normal file
View File

@@ -0,0 +1,50 @@
fireball={hab=-1,x=0,y=0,wait=0,flip=false,bb={x=0,y=0,w=4,h=4}}
function fireball.init(_hab,_x,_y,_flip)
if fireball.hab ~= -1 then return end
fireball.hab=_hab
fireball.x=_x
fireball.y=_y
fireball.flip=_flip
end
function fireball:draw()
circfill(fireball.x,fireball.y,3,16)
circfill(fireball.x,fireball.y,2,3)
circfill(fireball.x,fireball.y,1,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 fireball.x>96 then
fireball.hab=-1
return
elseif check_tile(fireball.hab,fireball.x,fireball.y)<tiletype.block then
if fireball.flip then
fireball.x=fireball.x-4
else
fireball.x=fireball.x+4
end
if fireball.x<-4 then
fireball.hab=-1
return
end
else
fireball.hab=-1
return
end
if fireball.hab==abad.hab then
if aabb(fireball,abad) and abad.update~=abad_state_crouch then
fireball.hab=-1
if abad.energia>0 then abad.energia=abad.energia-1 end
cls(3)
end
end
end
end