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()
    draw.circf(fireball.x,fireball.y,3,16)
    draw.circf(fireball.x,fireball.y,2,3)
    draw.circf(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
                abad_hurt(1)
            end
        end
    end
end
