Archived

This topic is now archived and is closed to further replies.

Le0

Blt - Bltfast probleme

Recommended Posts

Here is my prob, im making the tetris clone for Teej tutorial, and i came across a lil prob, in my game i use Blt for most of the pics but i use a function that writes caracaters at X Y the thing is that it uses Bltfast and in my game i could want to use clipping but i cant use bltfast and clipping. Anyone got any idea how to convert my function to bltfast? Oh btw atm it works perfectly because i simply dont use clipping yet and not sure if i will need them later but i''d like to know anyway.
//***********************
// DrawFonts, draw some text at X Y using ressource.bmp font file
// Note: Dont forget to flip the surfaces after using this function !
// G.lpDDSPrimary->Flip(NULL, 0);
void DrawFont(int x, int y, const char *pszText)
{    
    RECT rectSrc;
    int location = 0;
    int letterSpacing;
    char curr;
    static bool Done = FALSE;
    // Go through each character in the given string
    for (int i = 0; i < (int)strlen(pszText);i++)
    {
        // Get the current character
        curr = pszText;
        // Capital letter?
        if (curr >= ''A'' && curr <= ''Z'')
        {
            rectSrc.left = ALPHA_LARGE_STARTX + ((curr - ''A'') * ALPHA_LARGE_WIDTH);
            rectSrc.top = ALPHA_LARGE_STARTY;
            rectSrc.right = rectSrc.left + ALPHA_LARGE_WIDTH - 1;
            rectSrc.bottom = rectSrc.top + ALPHA_LARGE_HEIGHT - 1; 
            letterSpacing = ALPHA_LARGE_WIDTH;
        }                
        // Small letter?
        else if (curr >= ''a'' && curr <= ''z'')
        {
            rectSrc.left = ALPHA_SMALL_STARTX + ((curr - ''a'') * ALPHA_SMALL_WIDTH);
            rectSrc.top = ALPHA_SMALL_STARTY;
            rectSrc.right = rectSrc.left + ALPHA_SMALL_WIDTH - 1;
            rectSrc.bottom = rectSrc.top + ALPHA_SMALL_HEIGHT - 1;
            letterSpacing = ALPHA_SMALL_WIDTH;
        }
        // Number?
        else if (curr >= ''0'' && curr <= ''9'')
        {
            rectSrc.left = NUMERIC_STARTX + ((curr - ''0'') * NUMERIC_WIDTH);
            rectSrc.top = NUMERIC_STARTY;
            rectSrc.right = rectSrc.left + NUMERIC_WIDTH - 1;
            rectSrc.bottom = rectSrc.top + NUMERIC_HEIGHT - 1;
            letterSpacing = NUMERIC_WIDTH;
        }
        // Other (space or non-supported character)
        else if(curr == ''.'')
        {
            
            // Need Fix space too big
            rectSrc.left = SEMICOLON_STARTX;
            rectSrc.top = SEMICOLON_STARTY;
            rectSrc.right = rectSrc.left + NUMERIC_WIDTH - 1;
            rectSrc.bottom = rectSrc.top + NUMERIC_HEIGHT - 1;
            letterSpacing = NUMERIC_WIDTH;
        }
        else if(curr == ''!'')
        {            
            // Need Fix space too big
            rectSrc.left = EXCLAM_STARTX;
            rectSrc.top = EXCLAM_STARTY;
            rectSrc.right = rectSrc.left + NUMERIC_WIDTH - 1;
            rectSrc.bottom = rectSrc.top + NUMERIC_HEIGHT - 1;
            letterSpacing = NUMERIC_WIDTH;
        }
        else
        {
            // If it''s a space, move over one character (screen position)
            if (curr == '' '') location++;
            // Skip to the next character in the string
            continue;
        }
        // Draw this character to the backbuffer at the proper location
        G.lpDDSBack->BltFast(x + (location++ * letterSpacing), y,
            G.lpDDSFont,
            &rectSrc,
            DDBLTFAST_WAIT | DDBLTFAST_SRCCOLORKEY);
    }
} 

Share this post


Link to post
Share on other sites