Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Marian POIROT
Our awesome project
Commits
fff43626
Commit
fff43626
authored
Jun 25, 2021
by
Valentin MEUNIER
Browse files
debut de pause
parent
6f4f3fa1
Changes
2
Hide whitespace changes
Inline
Side-by-side
laby/affichage_txt.c
View file @
fff43626
...
...
@@ -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
}
laby/main.c
View file @
fff43626
...
...
@@ -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
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment