FBA The Creator

The True Multiplatform PC / PocketPC Opensource Development Tool - Read Only Mode - Kept only for historical purposes - Thank you all ;)
It is currently Thu Jun 08, 2023 6:21 am

All times are UTC




Post new topic  Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Thu Jun 19, 2008 11:32 am 
Offline
FBA Startup-Logo Creator
FBA Startup-Logo Creator
User avatar

Joined: Wed Jun 18, 2008 11:40 am
Posts: 100
Location: Brighton, UK
Currently all you can do is blend on a global level, would be LOVELY to set the blend value for each image!

_________________
http://www.boiledsweets.com


Top
   
PostPosted: Fri Jun 20, 2008 11:03 am 
Offline
Feejo Member
Feejo Member
User avatar

Joined: Fri Mar 28, 2008 8:07 am
Posts: 64
Location: Italy
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

_________________
Regards,

umbiomar
umbiomar@gmail.com


Top
   
PostPosted: Fri Jun 20, 2008 11:30 am 
Offline
FBA Startup-Logo Creator
FBA Startup-Logo Creator
User avatar

Joined: Wed Jun 18, 2008 11:40 am
Posts: 100
Location: Brighton, UK
AH! So thats how you do it - set the blend before the draw! CLEVER! Thanks!

_________________
http://www.boiledsweets.com


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Limited