-- 0,80 -> 112,112
batvio={
    name="batvio",
    hab=7,
    x=9,
    y=2,
    w=112,
    h=32,
    flip=true,
    frame=0,
    wait=0,
    step=0,
    energy=_energy,
    max_energy = _energy,
    hit=zombie.hit,
    update=zombie.update_normal, 
    draw=zombie.draw,
    jumpfwd=false,
    anim={},
    bb={x=16,y=3,w=80,h=29},
    can_warp=false,
    warping=false,
    shrink=1,
    d_shrink=1,
    angle=0,
    d_angle=15,
    dying=false,
    death_time=40,
    enabled=false,
    disable_reason="",
}

function batvio.init()
    local world_x, world_y = coords.room_to_world(batvio.hab,batvio.x,batvio.y)
    batvio.x=world_x
    batvio.y=world_y
end

function batvio.draw()
    if not batvio.enabled then return end
    
    local curr_sf = surf.source()
    surf.source(tiles2)
    local scr_x, scr_y = viewp:screen_coords( batvio.x, batvio.y )
    local motor_pos = scr_x
    local cabina_pos = scr_x+32
    if batvio.flip then
        motor_pos = scr_x + batvio.w-32
        cabina_pos = scr_x
    end
    -- foc del propulsor
    if batvio.step % 2 == 0 then
        pal.subpal(3,0)
        pal.subpal(7,0)
        pal.subpal(8,0)
    end
    draw.surf(0,80,32,batvio.h,motor_pos,scr_y,32,batvio.h,batvio.flip)
    pal.subpal(3)
    pal.subpal(7)
    pal.subpal(8)
    -- resta de l'avio
    draw.surf(32,80,batvio.w-32,batvio.h,cabina_pos,scr_y,batvio.w-32,batvio.h,batvio.flip)
    surf.source(curr_sf)
end

function batvio.hit()
end

function batvio.update()
    if not batvio.enabled then return end
    
    batvio.step = batvio.step +1
end