Forum

[psp] How Do I make a .lmp Fade out?

Discuss programming topics for the various GPL'd game engine sources.

Moderator: InsideQC Admins

[psp] How Do I make a .lmp Fade out?

Postby Mexicouger » Fri Oct 01, 2010 4:31 am

I made a graphic show up on the HUD for like 3 seconds, And when It removes itself, It just disappears. Is there a way I can add something to the engine to make the graphic fade instead? Much help is appreciated!
User avatar
Mexicouger
 
Posts: 514
Joined: Sat May 01, 2010 10:12 pm

Re: [psp] How Do I make a .lmp Fade out?

Postby Baker » Fri Oct 01, 2010 4:58 am

Mexicouger wrote:I made a graphic show up on the HUD for like 3 seconds, And when It removes itself, It just disappears. Is there a way I can add something to the engine to make the graphic fade instead? Much help is appreciated!


Take a look at "flashon" in sbar.c, notice that it has the time an item was picked up. Look for "gettime" or something to that effect.

In gl_draw.c (video_hardware_draw.cpp in PSP), there is Draw_AlphaPic [hopes the PSP has that, it is standard in GLQuake gl_draw.c but I haven't looked recently at PSP video_hardware_draw.cpp]. Alpha is a value from 0 to 1 on how transparent the picture is. 0 means = invisible. 1 = solid. 0.5 would be half transparent.

Render an sbar pic with alpha = 1 for the first second, alpha = 0.66 for the second second and 0.33 for the third second and then simply don't draw it any longer if gettime > whatever seconds.

You'll have to get your hands a bit dirty, although I haven't look at ... say.. the Kurok HUD lately, normally sbar.c doesn't call Draw_AlphaPic directly but rather calls Sbar_DrawPic or something so you'll need to either modify Sbar_DrawPic to include an alpha value
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Postby Baker » Fri Oct 01, 2010 5:28 am

See cl.item_gettime[i] in sbar.c ....

http://bladebattles.com/kurok/SVN/sbar.c

Code: Select all
/*
===============
Sbar_DrawInventory
===============
*/
void Sbar_DrawInventory (void)
{
    int        i;
    char    num[6];
    float    time;
    int        flashon;

    if (rogue)
    {
        if ( cl.stats[STAT_ACTIVEWEAPON] >= RIT_LAVA_NAILGUN )
            Sbar_DrawPic (0, -24, rsb_invbar[0]);
        else
            Sbar_DrawPic (0, -24, rsb_invbar[1]);
    }
    else if (!kurok)
        Sbar_DrawPic (0, -24, sb_ibar);

// weapons
    if (!kurok)
    {
    for (i=0 ; i<7 ; i++)
    {
        if (cl.items & (IT_SHOTGUN<<i) )
        {
            time = cl.item_gettime[i];
            flashon = (int)((cl.time - time)*10);
            if (flashon >= 10)
            {
                if ( cl.stats[STAT_ACTIVEWEAPON] == (IT_SHOTGUN<<i)  )
                    flashon = 1;
                else
                    flashon = 0;
            }
            else
                flashon = (flashon%5) + 2;

         Sbar_DrawPic (i*24, -16, sb_weapons[flashon][i]);

            if (flashon > 1)
                sb_updates = 0;        // force update to remove flash
        }
    }
    }


And this part determines the time elapsed ...

time = cl.item_gettime[i];
flashon = (int)((cl.time - time)*10); // Baker: I'm thinking cl.time is in milliseconds but I could be wrong


Sbar_DrawPic ... you need to add one more argument for alpha.

/*
=============
Sbar_DrawPic
=============
*/
void Sbar_DrawPic (int x, int y, qpic_t *pic, float alpha)
{


You will need to add ,1 to specify no transparency to ALL instances of Sbar_DrawPic in sbar.c to support the new param.

And do some code like inside Sbar_DrawPic ...

Code: Select all
if (alpha == 1.0f)
  Do it old way;
else
  Draw_AlphaPic (x,y, pic, alpha); // Draw semi-transparent


The PSP Quake versions should already support alpha drawing as video_hardware_draw.cpp has "Draw_AlphaPic" in it ...

http://bladebattles.com/kurok/SVN/psp/v ... e_draw.cpp
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am


Return to Engine Programming

Who is online

Users browsing this forum: No registered users and 1 guest