Letter Fade

New to FreeBASIC? Post your questions here.
TurtleProgrammer
Posts: 37
Joined: Jan 26, 2017 7:54

Letter Fade

Postby TurtleProgrammer » Apr 02, 2017 0:29

Is there a way to make characters fade. Like with images you can use ALPHA to make the images fade away. I want to do the same with characters for a new game.
D.J.Peters
Posts: 7949
Joined: May 28, 2005 3:28

Re: Letter Fade

Postby D.J.Peters » Apr 02, 2017 3:35

Use draw string to draw the chars/word in an image (nChars*8,8) and then use your prefered image alpha blit method.

Joshy
dodicat
Posts: 6163
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: Letter Fade

Postby dodicat » Apr 02, 2017 11:22

If you don't want to use images then use an alpha blend screen (64)
(Adjust the Limit to set your fade rate).
Example

Code: Select all

'do this
'==========================================================
#define _Imap(a,b,_x_,c,d) ((d)-(c))*((_x_)-(a))\((b)-(a))+(c)
#define fade _Imap(0,Limit,counter,0,255)
dim as long counter,limit=50,k=1
'========================================================
limit=500  'speed adjuster (bigger is slower)
'======================================================


screen 19,32,,64 'alpha screen
color ,rgb(0,100,255) 'background


  dim as string s="ABCDEFGHIJKLMNOPQRSTUVWXYZ"

do
    'do this
    '======================================
    counter+=k
    if counter>=Limit or counter<=0 then k=-k
    '=======================================
   
   
   
        screenlock
        cls
        circle(400,300),50,rgb(200,80,0),,,,f
        draw string(320,300),s,rgba(255,255,255,fade)
        draw string(320,330),s,rgba(0,0,0,255-fade)
       
        draw string(320,400),s,rgba(255,0,0,fade)
        draw string(320,400),s,rgba(0,255,0,255-fade)
        screenunlock
       
        sleep 1,1
    loop until len(inkey)
   
     

Return to “Beginners”

Who is online

Users browsing this forum: MSN [Bot] and 1 guest