--------------------------------------------------- 
-- FBA Tutorials
--
-- Tutorial / 04 / Draw a part of an image
--
--------------------------------------------------- 
--
-- This sample will show you how to draw a part of an image
-- Please note: this sample is running in "landscape" mode
-- You can specify a screen orientation for your application
-- simply selecting it from "Build->Project Settings" menu.
-- (you will find other cool settings there ;)
--
--------------------------------------------------- 

-- this are global variable (you can see them inside all functions)
local step, dir
step = 0
dir = 0

loadimage(0, "back.png")



function onmainloop()	

         local width, height
         
         height = imageheight(0)
         width = imagewidth(0)

         clear(0,0,0)
         
         if dir == 0 then
            step = step + 4
            if step > 100 then 
               dir = 1
            end
         else
            step = step - 4
            if step < 0 then 
               dir = 0
            end
         end
         
         drawimage(0, step, step, step, step, width-step, height-step)

         if (mousedown() > 0) then
            quit()
         end

end
