Add "You Won" message

This commit is contained in:
David Husička 2021-12-14 21:33:10 +01:00
parent bdd4e17cad
commit d8ccbb2707
5 changed files with 163 additions and 0 deletions

BIN
res/1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

68
res/1.svg Normal file
View File

@ -0,0 +1,68 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="800"
height="920"
viewBox="0 0 211.66666 243.41667"
version="1.1"
id="svg5"
inkscape:version="1.1.1 (3bf5ae0d25, 2021-09-20, custom)"
sodipodi:docname="1.svg"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<sodipodi:namedview
id="namedview7"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:document-units="mm"
showgrid="false"
units="px"
width="800px"
inkscape:zoom="1.0180501"
inkscape:cx="358.03739"
inkscape:cy="281.42033"
inkscape:window-width="1920"
inkscape:window-height="1064"
inkscape:window-x="0"
inkscape:window-y="16"
inkscape:window-maximized="1"
inkscape:current-layer="layer1" />
<defs
id="defs2">
<rect
x="16.997874"
y="64.511345"
width="142.45095"
height="94.937476"
id="rect9954" />
</defs>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<rect
style="fill:#ffcc73;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:5;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:stroke fill markers"
id="rect38"
width="39.6875"
height="39.6875"
x="2.5"
y="2.5" />
<text
xml:space="preserve"
transform="matrix(0.26458333,0,0,0.26458333,-1.0730707,-1.9593439)"
id="text9952"
style="font-style:normal;font-weight:normal;font-size:64px;line-height:1.25;font-family:sans-serif;white-space:pre;shape-inside:url(#rect9954);fill:#000000;fill-opacity:1;stroke:none;text-align:center"
x="57.703987"
y="0"><tspan
x="64.511658"
y="123.71172"
id="tspan9808">ඞ</tspan></text>
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.1 KiB

BIN
res/you_won.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

89
res/you_won.svg Normal file
View File

@ -0,0 +1,89 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="800"
height="920"
viewBox="0 0 211.66666 243.41667"
version="1.1"
id="svg5"
inkscape:version="1.1.1 (3bf5ae0d25, 2021-09-20, custom)"
sodipodi:docname="you_won.svg"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<sodipodi:namedview
id="namedview7"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:document-units="mm"
showgrid="false"
units="px"
width="800px"
inkscape:zoom="1.0180501"
inkscape:cx="379.64733"
inkscape:cy="283.87601"
inkscape:window-width="1920"
inkscape:window-height="1064"
inkscape:window-x="0"
inkscape:window-y="16"
inkscape:window-maximized="1"
inkscape:current-layer="layer1" />
<defs
id="defs2">
<rect
x="70.262996"
y="57.504998"
width="686.5568"
height="303.83988"
id="rect12444" />
<rect
x="16.997874"
y="64.511345"
width="142.45095"
height="94.937476"
id="rect9954" />
</defs>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<rect
style="fill:#ededed;fill-opacity:0.91326994;stroke:none;stroke-width:4.99999;stroke-linejoin:round;paint-order:stroke fill markers"
id="rect3956"
height="243.41667"
x="0"
y="1.110223e-16"
width="211.66667"
inkscape:export-filename="/home/dudi/c/2048/res/game_over.png"
inkscape:export-xdpi="96"
inkscape:export-ydpi="96" />
<text
xml:space="preserve"
transform="scale(0.26458333)"
id="text12442"
style="fill:black;fill-opacity:1;line-height:1.25;stroke:none;font-family:sans-serif;font-style:normal;font-weight:normal;font-size:40px;white-space:pre;shape-inside:url(#rect12444)"
inkscape:export-filename="/home/dudi/c/2048/res/game_over.png"
inkscape:export-xdpi="96"
inkscape:export-ydpi="96" />
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:22.5778px;line-height:1.25;font-family:sans-serif;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
x="107.58397"
y="63.440025"
id="text13308"
inkscape:export-filename="/home/dudi/c/2048/res/game_over.png"
inkscape:export-xdpi="96"
inkscape:export-ydpi="96"><tspan
sodipodi:role="line"
id="tspan13306"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:22.5778px;font-family:'URW Gothic';-inkscape-font-specification:'URW Gothic Bold';text-align:center;text-anchor:middle;stroke-width:0.264583"
x="107.58397"
y="63.440025">You Won</tspan></text>
</g>
</svg>

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

@ -16,6 +16,7 @@ SDL_Texture *tile_texture = NULL;
SDL_Texture *tile_textures[13];
SDL_Rect tile_size;
SDL_Texture *game_over_texture = NULL;
SDL_Texture *you_won_texture = NULL;
TTF_Font *Sans = NULL;
SDL_Color Black = { 0, 0, 0 };
@ -69,6 +70,7 @@ void gui_init() {
SDL_QueryTexture(tile_texture, NULL, NULL, &tile_size.w, &tile_size.h);
game_over_texture = texture_from_png("res/game_over.png");
you_won_texture = texture_from_png("res/you_won.png");
Sans = TTF_OpenFont("/usr/share/fonts/liberation/LiberationSerif-Regular.ttf", 92);
}
@ -81,6 +83,7 @@ void gui_destroy() {
SDL_DestroyTexture(tile_textures[i]);
}
SDL_DestroyTexture(game_over_texture);
SDL_DestroyTexture(you_won_texture);
TTF_Quit();
// Quit SDL subsystems
@ -168,6 +171,9 @@ void gui_loop(Game *game) {
// render game over screen
SDL_RenderCopy(window_renderer, game_over_texture, NULL, NULL);
}
else if (game->won) {
SDL_RenderCopy(window_renderer, you_won_texture, NULL, NULL);
}
SDL_RenderPresent(window_renderer);
needs_redraw = false;