SDL_TTF text centering code

SDL_TTF text centering code…

Hi,

I asked about text centering with SDL_TTF.

Well, after a few cups of coffee, I figured it out:------------------------------------------------------------------------------

if (xCenter == true)
{
TTF_SizeText(FntCourier, text, &textWidth, &textHeight);
xScreenPos = (640 - textWidth)/2;
}


Answered my own question.

My SDL based PC Windows Tetris game project:
http://www.silentheroproductions.com/tetribattle3_100percentforpcwindows.htm

(http://www.silentheroproductions.com/tetribattle3_100percentforpcwindows.htm)
(TetriBattle 3 100%[TM])

Jesse “JeZ+Lee” Palser, BS, A+, Network+, MCP
SLNTHERO at AOL.com
Silent Hero Productions ®
"Fun, little games for when you don’t have time to save the world.[TM]"
www.SilentHeroProductions.com (http://www.silentheroproductions.com/)

I would recommend a more flexible solution to that.

if (xCenter == true)
{
TTF_SizeText(FntCourier, text, &textWidth, &textHeight);
xScreenPos = (screenWidth - textWidth)/2; // Fix for variable screen size
}

That way regardless of what screen size you or the end user are using, it
will always be centered.

HTH,
RichardOn 4/19/06, SlntHero at aol.com wrote:

SDL_TTF text centering code…

Hi,

I asked about text centering with SDL_TTF.

Well, after a few cups of coffee, I figured it out:


if (xCenter == true)
{
TTF_SizeText(FntCourier, text, &textWidth, &textHeight);
xScreenPos = (640 - textWidth)/2;
}


Answered my own question.

My SDL based PC Windows Tetris game project:

http://www.silentheroproductions.com/tetribattle3_100percentforpcwindows.htm
(TetriBattle 3 100%[TM])

Jesse “JeZ+Lee” Palser, BS, A+, Network+, MCP
SLNTHERO at AOL.com
Silent Hero Productions ®
"Fun, little games for when you don’t have time to save the world.[TM]"
www.SilentHeroProductions.com http://www.silentheroproductions.com/


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


Richard J Hancock
RJH Computers
http://www.rjhcomputers.com