home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 103 / CD-ROM 103.iso / edu / martianwin / src / text.h < prev    next >
Encoding:
Text File  |  2003-08-11  |  1.0 KB  |  34 lines

  1. void T_Print(SDL_Surface *font, int x, int y, char *str, ...)  //Rutina para imprimir texto estatico en la pantalla
  2. {
  3.     int font_h=font->h; int font_w=font->w/91; // 91 es la cantidad de caracteres en el archivo de font
  4.     SDL_Rect srctxt; // la posicion donde se encuentra el caracter en el bitmap
  5.     SDL_Rect dsttxt; // la posicion donde se imprimira el texto
  6.  
  7.     char texto [100];
  8.     va_list ap;
  9.     va_start(ap, str);
  10.     vsprintf(texto, str, ap);
  11.     va_end(ap);
  12.     
  13.     srctxt.w = font_w;
  14.     srctxt.h = font_h;
  15.     srctxt.y = 0;
  16.     int linecounter = 0 ; // este contador se utiliza para saber en que linea imprimimos el texto
  17.     int charpos = 0;
  18.     for(int charcounter = 0; charcounter <= (strlen(texto));charcounter++)
  19.     {
  20.     int curchar=texto[charcounter];
  21.     if(curchar == 94)
  22.     {
  23.         linecounter++;
  24.         charpos = -1;
  25.     }
  26.     srctxt.x = (curchar - 32) * font_w;
  27.     dsttxt.x = (x + (charpos * font_w));
  28.     dsttxt.y = (y + (linecounter * font_h));
  29.     charpos++;
  30.     SDL_BlitSurface(font, &srctxt, screen, &dsttxt);
  31.     }
  32. }
  33.  
  34.