Commit fff43626 authored by Valentin MEUNIER's avatar Valentin MEUNIER
Browse files

debut de pause

parent 6f4f3fa1
......@@ -36,3 +36,40 @@ void affichage_txt(SDL_Window *window,SDL_Renderer *renderer)
//ne pas oublier le TTF_Quit() dans le programme principal
}
void affichage_txt_pause(SDL_Window *window,SDL_Renderer *renderer)
{
SDL_Rect window_dimensions = {0}, pos = {0, 0, 0, 0};
SDL_GetWindowSize(window,&window_dimensions.w,&window_dimensions.h);
if (TTF_Init() < 0) exit(EXIT_FAILURE);
TTF_Font* font = NULL; // la variable 'police de caractère'
font = TTF_OpenFont("Pacifico.ttf", 65); // La police à charger, la taille désirée
if (font == NULL) exit(EXIT_FAILURE);
SDL_Color color = {230, 200, 0, 255}; // la couleur du texte
SDL_Surface* text_surface = NULL; // la surface (uniquement transitoire)
text_surface = TTF_RenderText_Blended(font, "pause\n", color); // création du texte dans la surface
if (text_surface == NULL) exit(EXIT_FAILURE);
SDL_Texture* text_texture = NULL; // la texture qui contient le texte
text_texture = SDL_CreateTextureFromSurface(renderer, text_surface); // transfert de la surface à la texture
if (text_texture == NULL) exit(EXIT_FAILURE);
SDL_FreeSurface(text_surface); // la texture ne sert plus à rien
SDL_QueryTexture(text_texture, NULL, NULL, &pos.w, &pos.h); // récupération de la taille (w, h) du texte
pos.x= (window_dimensions.w-pos.w)/4;
pos.y= 0;
SDL_RenderCopy(renderer, text_texture, NULL, &pos); // Ecriture du texte dans le renderer
SDL_DestroyTexture(text_texture);
TTF_CloseFont(font);
TTF_Quit();
//ne pas oublier le TTF_Quit() dans le programme principal
}
......@@ -458,7 +458,7 @@ int main (int argc, char** argv)
{
relancer=0;
affiche_carte=0;
affichage_txt(window, renderer);
affichage_txt_pause(window, renderer);
}
SDL_Delay(30);
SDL_RenderPresent(renderer);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment