--------------------------------------------------- 
-- FBA Tutorials
--
-- Tutorial / 08 / Simple fading screen
--
--------------------------------------------------- 
--
-- Show a simple fading screen
--
--------------------------------------------------- 


loadimage(0, "back.png")

local blend = 255
local dir = 0

function onmainloop()	
         drawimage(0,0,0)
         
         if dir == 0 then
            blend = blend - 5
            if blend == 0 then
               dir = 1
            end
         else
            blend = blend + 5
            if blend == 255 then
               dir = 0
            end         
         end
         
         fadescreen(blend)
         
         if mousedown() > 0 then
            quit()
         end
end


--
-- our fade function
--
function fadescreen(value)
         -- apply transparency to next draw operations
         blending( blend )
         clear(0,0,0)
                  
         -- reset transparency
         blending(255)
end
