About Store Forum Documentation Contact



Post Reply 
fade with LerpRS() question
Author Message
craksy Offline
Member

Post: #1
fade with LerpRS() question
ok i got a quesion about fading with the LerpRS() function.
i rewrote the Alpha() function from Blood massacre a little bit to make it easier to understand (for me at least), so now i have this:
Code:
/******************************************************************************/
#include "stdafx.h"
#include "Main.h"
/******************************************************************************/
Image img, img2;
/******************************************************************************/

static Flt Alpha(Flt IN_START, Flt IN_END, Flt OUT_START, Flt OUT_END)
{
    Flt t = StateActive->time();
    if(t <= IN_END){
        return LerpRS(IN_START, IN_END, t);
    }
    else{
        return LerpRS(OUT_END, OUT_START, t);
    }
}

bool initIntro()
{
    img  = "logo2.gfx";
    img2 = "craksyLogo.gfx";
    return true;
}

bool updateIntro()
{
    if(StateActive->time() >= 15)stateMenu.set(0.5);
    return true;
}

void drawIntro()
{
    D.clear(WHITE);
    img.drawFs (ColorAlpha(Alpha(1,3,6,8)));
    img2.drawFs(ColorAlpha(Alpha(8,10,10,0)));
}
/******************************************************************************/
State stateIntro(updateIntro, drawIntro, initIntro);
/******************************************************************************/

the problem is... i still don't have the slightest idea of how this works :S
i tried to take a look at the LerpRS() function, but i didn't really get it :/
it would be nice if one of you guys could explain it to me smile and in a language i understand xD


Thanks in advance pfft

-Craksy
10-10-2009 05:16 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
Re: fade with LerpRS() question
LerpRS gets the "step" between two values (0..1)

have a range 0..100

if you use LerpRS(0,100, 0) you'll get 0.0
if you use LerpRS(0,100, 50) you'll get 0.5
if you use LerpRS(0,100, 100) you'll get 1.0


have a range 10..20

if you use LerpRS(10,20, 10) you'll get 0.0
if you use LerpRS(10,20, 15) you'll get 0.5
if you use LerpRS(10,20, 20) you'll get 1.0
10-10-2009 01:50 PM
Find all posts by this user Quote this message in a reply
craksy Offline
Member

Post: #3
Re: fade with LerpRS() question
aah grin c that made it alot easier to understand xD

thanks a lot smile
10-10-2009 02:24 PM
Find all posts by this user Quote this message in a reply
Post Reply