#include #include #include int main(int argc, char *argv[]) { // El espacio es el 32 y de ahí para alante SDL_Surface *screen; SDL_Surface *fondo; SDL_Surface *imagen; SDL_Event event; SDL_Rect dstrect = {0, 0, 0, 0}; char *data[] = { "Opcasdfaion1", "Oasfd", "Opcion lol", "Opcion lolafd", "opcion rlz" }; int filas = 6; int columnas = 16; int i, x; //char data[] = "Palabras que molan"; if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) == -1) { printf("No se ha iniciado SDL"); } screen = SDL_SetVideoMode(320, 240, 16, SDL_SWSURFACE); SDL_WM_SetCaption("Escribir palabras en pantalla", NULL); imagen = SDL_LoadBMP("letras.bmp"); /* printf("%d %d %d\n", sizeof(data), sizeof(char *), ); fflush(stdout); */ if (imagen == NULL) SDL_Quit(); int lancho = imagen->w/columnas; int lalto = imagen->h/filas; int letra, maxx = 0; for (x = 0; x < sizeof(data) / sizeof(char *); x++) { for (i = 0; i < strlen(data[x]); i++) { letra = data[x][i] - 32; SDL_Rect letrarect = {letra % columnas * lancho, letra / columnas * lalto + 2, lancho, lalto}; SDL_BlitSurface(imagen, &letrarect, screen, &dstrect); dstrect.x += lancho; } if (dstrect.x > 0) maxx = dstrect.x; dstrect.x = 0; dstrect.y += lalto + 1; } SDL_UpdateRect(screen, 0, 0, 320, 240); while (SDL_WaitEvent(&event)) { if (event.type == SDL_QUIT) break; } SDL_Quit(); return 0; }