// Using Fonts in SDL #include #include #include "bomberclone.h" #include "gfx.h" void draw_text (int x, int y, char *text, int white) { int i, c; SDL_Rect src, dest; src.y = 0; dest.w = src.w = gfx.font.size.x; dest.h = src.h = gfx.font.size.y; dest.x = x; dest.y = y; for (i = 0; text[i] != 0; i++) { c = text[i]; src.x = gfx.font.size.x * (c & 15); src.y = gfx.font.size.y * ((c & 240) >> 4); if (white) SDL_BlitSurface (gfx.font.image, &src, gfx.screen, &dest); else SDL_BlitSurface (gfx.font1.image, &src, gfx.screen, &dest); dest.x += gfx.font.size.x-4; } gfx_AddUpdateRect (x, y, dest.x - x, dest.h); };