what you mean with individual blend?
I twicked your code (below) to simulate individual blending (and honestly the final result is amazing!!)
Code: --------------------------------------------------- -- 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, "cone.jpg") loadimage(1, "tongue.jpg") loadimage(2, "alien.jpg") loadimage(3, "devil.jpg")
local imp={} local maximps=100
for i=0, maximps do imp[i]={} imp[i]["x"]=math.random(0, screenwidth() - 32) imp[i]["y"]=math.random(0, screenheight() -32) imp[i]["x_vel"] = math.random(1) imp[i]["x_speed"] = math.random(1,2) imp[i]["y_speed"] = math.random(1,2) imp[i]["y_vel"] = math.random(1) imp[i]["type"] = math.random(0,2) -- choose a random value for blending imp[i]["blend"] = math.random(64,255) end
colormask(1, 0, 0,0)
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 -- drawimage(0, 0, 0 ) drawimage(0,0,0) for i=0, maximps do if imp[i]["x_vel"] == 0 then if imp[i]["x"] < screenwidth()-32 then imp[i]["x"] = imp[i]["x"] + imp[i]["x_speed"] else imp[i]["x_vel"] = 1 end else if imp[i]["x"] > 1 then imp[i]["x"] = imp[i]["x"] - imp[i]["x_speed"] else imp[i]["x_vel"] = 0 end end if imp[i]["y_vel"] == 0 then if imp[i]["y"] < screenheight()-32 then imp[i]["y"] = imp[i]["y"] + imp[i]["y_speed"] else imp[i]["y_vel"] = 1 end else if imp[i]["y"] > 1 then imp[i]["y"] = imp[i]["y"] - imp[i]["y_speed"] else imp[i]["y_vel"] = 0 end end -- set sprite blending before drawing blending( imp[i]["blend"] ) if imp[i]["type"] == 0 then drawimage(1, imp[i]["x"], imp[i]["y"]) elseif imp[i]["type"] == 1 then drawimage(2, imp[i]["x"], imp[i]["y"]) elseif imp[i]["type"] == 2 then drawimage(3, imp[i]["x"], imp[i]["y"]) end end -- reset blending for future draws blending(255) if (mousedown() > 0) then quit() end
end
|