You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
730 B
37 lines
730 B
// Using Fonts in SDL
|
|
|
|
#include <string.h>
|
|
#include <SDL.h>
|
|
|
|
#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);
|
|
};
|
|
|