REMOVE THIS TOPIC.
I SOLVED THE PROBLEM.
SDL Keypress to ASCII PROBLEM!
Use key.unicode instead of key.sym? Not sure if it already handles things such as shift and etc, but it's a start...
EDIT:
Misread the post.
Generally, you'd have a table of SDL_Rects you index into to select where in the bitmap that character resides:
Slightly pseudo-code:
EDIT:
Misread the post.
Generally, you'd have a table of SDL_Rects you index into to select where in the bitmap that character resides:
Slightly pseudo-code:
SDL_Rect glyphBounds[256];
// load into file
std::ifstream fs( "bitmap_font.txt" );
for ( int idx = 0; idx < 256 && fs >> glyphBounds[idx]; ++idx )
;
// draw:
std::string str = "Hello";
int x = 0, y = 0;
for ( int idx = 0; idx < str.length(); ++idx ) {
const SDL_Rect& r = glyphBounds[str[idx]];
draw( x, y, bmpFont, r );
x += r.width;
}
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement