1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
| #include <stdlib.h>
#include <SDL.h>
#include <SDL_ttf.h>
#define MAX 20
int main ( int argc, char** argv )
{
[...]
char touche;
char chaine[MAX];
unsigned char l=0,i;
SDL_Surface *message = NULL; // pour écrire le message
TTF_Font *font; // pour la police de caractère choisie.
SDL_Color textColor = { 255, 255, 255,0 }; //La couleur du Font
[...]
font = TTF_OpenFont( "SCRIPTIN.ttf", 28 );
//S'il y a une erreur dans le chargement du Font
if( font == NULL ) {
return false;
}
[...]
// DRAWING STARTS HERE
// clear screen
SDL_FillRect(screen, 0, SDL_MapRGB(screen->format, 0, 0, 0));
// draw bitmap
SDL_BlitSurface(bmp, 0, screen, &dstrect);
if (chaine[0]!=0) // pour ne rien afficher tant que chaine est vide
{
//Mise en place du texte sur la surface message
message = TTF_RenderText_Solid( font, chaine, textColor );
//S'il y a une erreur dans la mise en place du texte
if( message == NULL )
{
printf("Erreur place txt");
return 1;
}
}
//Application des images sur l'écran
SDL_BlitSurface( message,0, screen,&pl_tx );
// DRAWING ENDS HERE
// finally, update the screen :)
SDL_Flip(screen);
} // end main loop
[...]
} |
Partager