- Imp and fireball implemented
This commit is contained in:
50
fireball.lua
Normal file
50
fireball.lua
Normal 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
|
||||
Reference in New Issue
Block a user