From 7bdcc64815ab913afffb23dd4ecefbaabdb9915d Mon Sep 17 00:00:00 2001 From: stpohle Date: Fri, 25 Jul 2003 23:46:25 +0000 Subject: [PATCH] Single Player Result Screen --- src/font.c | 9 +++++- src/font.h | 1 + src/game.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++++------ 3 files changed, 80 insertions(+), 10 deletions(-) diff --git a/src/font.c b/src/font.c index bbb7f4d..28af630 100644 --- a/src/font.c +++ b/src/font.c @@ -1,4 +1,4 @@ -/* $Id: font.c,v 1.6 2003/07/22 18:29:08 stpohle Exp $ */ +/* $Id: font.c,v 1.7 2003/07/25 23:46:25 stpohle Exp $ */ // Using Fonts in SDL #include @@ -73,3 +73,10 @@ void font_free() { } }; + +void font_drawbold (int x, int y, char *text, int size, int bold) { + font_draw (x - bold, y, text, size); + font_draw (x + bold, y, text, size); + font_draw (x, y - bold, text, size); + font_draw (x, y + bold, text, size); +}; \ No newline at end of file diff --git a/src/font.h b/src/font.h index 1939a63..614bcde 100644 --- a/src/font.h +++ b/src/font.h @@ -15,6 +15,7 @@ extern _font font[3]; extern void font_setcolor (unsigned char r, unsigned char g, unsigned char b, int size); extern void font_draw (int x, int y, char *text, int size); +extern void font_drawbold (int x, int y, char *text, int size, int bold); extern void font_load (); extern void font_free (); diff --git a/src/game.c b/src/game.c index 3c73fe6..c1c8bdb 100644 --- a/src/game.c +++ b/src/game.c @@ -1,4 +1,5 @@ -/* game.c - procedures for the game. */ +/* $Id: game.c,v 1.44 2003/07/25 23:46:25 stpohle Exp $ + game.c - procedures for the game. */ #include #include @@ -287,24 +288,85 @@ void game_showresult () { char text[255]; SDL_Event event; Uint8 *keys; - int done = 0, keypressed = 0, x, y; - + int done = 0, keypressed = 0, x, y, i, p; + menu_displaytext ("Loading..", "Please Wait", 32, 128, 32); + dest.x = dest.y = 0; + dest.w = gfx.res.x; + dest.h = gfx.res.y; + gfx_load_players (64, 64); + draw_logo (); strcpy (text, "Game Result"); x = (gfx.res.x - (font[2].size.x * strlen (text)) - 64) / 2; - y = 64; + y = 0; + font_setcolor (128, 128, 0, 2); + font_drawbold (x, y, text, 2, 2); + font_setcolor (255, 255, 128, 2); + font_draw (x, y, text, 2); + y += font[2].size.x; + + for (i = 1, p = 0; p < MAX_PLAYERS; p++) + if (PS_IS_alife (bman.players[p].state)) + i++; + + if (i == 1) + strcpy (text, "Game Over"); + else + strcpy (text, "Draw Game"); + + x = (gfx.res.x - (font[2].size.x * strlen (text)) - 64) / 2; font_setcolor (128, 128, 0, 2); - font_draw (x - 2, y, text, 2); - font_draw (x + 2, y, text, 2); - font_draw (x, y - 2, text, 2); - font_draw (x, y + 2, text, 2); + font_drawbold (x, y, text, 2, 2); font_setcolor (255, 255, 128, 2); font_draw (x, y, text, 2); + y += font[2].size.x + 8; + + strcpy (text, "Hit [CTRL], [RETURN] or [STRG]"); + x = (gfx.res.x - (font[1].size.x * strlen (text)) - 64) / 2; + font_setcolor (128, 128, 0, 1); + font_drawbold (x, gfx.res.y - font[1].size.y - 2, text, 1, 1); + font_setcolor (255, 255, 128, 1); + font_draw (x, gfx.res.y - font[1].size.y - 2, text, 1); + + for (i = 1, p = 0; p < MAX_PLAYERS; p++) { + if (PS_IS_used (bman.players[p].state)) { + if (!i) { + i = 1; + x = (gfx.res.x / 2) + 16; + } + else if (i) { + i = 0; + y = y + 80; + x = 16; + } + + font_setcolor (128, 128, 128, 0); + font_drawbold (x + 80, y + 4, bman.players[p].name, 0, 2); + if (PS_IS_alife (bman.players[p].state)) + font_setcolor (255, 255, 0, 0); + else + font_setcolor (196, 196, 196, 0); + font_draw (x + 80, y + 4, bman.players[p].name, 0); + + sprintf (text, "%3d", bman.players[p].wins); + font_draw (x + 80 + (LEN_PLAYERNAME+2) * font[0].size.x, y + 4, text, 0); + sprintf (text, "%3d", bman.players[p].points); + font_draw (x + 80 + (LEN_PLAYERNAME+5) * font[0].size.x, y + 4, text, 0); + + dest.x = x; + dest.y = y; + src.w = dest.w = bman.players[p].gfx->ani.w; + src.h = dest.h = bman.players[p].gfx->ani.h; + src.x = bman.players[p].gfx->ani.w * down; + src.y = 0; + } + } gfx_blitdraw (); SDL_Flip (gfx.screen); - + gfx_free_players (); + while (!done) { /* do the keyboard handling */ if (SDL_PollEvent (&event) != 0)