--------------------------------------------------- 
-- FBA Tutorials
--
-- Tutorial / 02 / DrawImage
--
--------------------------------------------------- 
--
-- This sample will show you how to load images from your resources
-- and then draw them all around your screen ;)
--
--------------------------------------------------- 

--
-- load an image from resource and place it in images slot 0
-- note: for each load/create function requiring a slot (sounds, musics, fonts, grids etc)
-- you can also omit the slot and let FBA load it in first available free slot.
-- For example you can load the image in first free slot available with:
--
-- local imageslot = loadimage("block.png")
--
-- Then you will have the number of slot just created inside the variable "imageslot"
-- and draw it with: drawimage(imageslot, x, y)
--
-- Every image has a trasparent color that won't be drawed on the screen
-- Transparent color is global inside a project (you can set it in Project Settings)
--
loadimage(0, "block.png")


function onmainloop()	

         -- declare your variable, this is optional but very suggested
         -- because declared variables will be visible in the stack dump
         -- panel when you debug your program step by step
         local maxwidth, maxheight
         
         -- clear your screen with black
         clear(0,0,0)
         
         -- get size of the window
         maxwidth = screenwidth()
         maxheight = screenheight()
                  
         -- draw images around your screen
         for i=0, 50 do
             drawimage(0, math.random(0, maxwidth), math.random(0, maxheight) )
         end
         
         if (mousedown() > 0) then
            quit()
         end

end
