From d86a0859308bd6f4846f4b857570797ebd9540c2 Mon Sep 17 00:00:00 2001 From: stpohle Date: Wed, 6 Apr 2005 21:17:42 +0000 Subject: [PATCH] fixed: playergfx overlapped the player name. if you selected no player you will see for you or anyone else who have no player a ghost player. --- ChangeLog | 8 +++++++- configure.in | 2 +- include/gfx.h | 4 +++- src/game.c | 34 ++++++++++++++++++++++++++-------- src/gfx.c | 21 ++++++++++++++++++++- src/packets.c | 7 +++++-- 6 files changed, 62 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index be64f46..b24fca8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,10 @@ -$Id: ChangeLog,v 1.99 2005/03/28 18:20:18 stpohle Exp $ +$Id: ChangeLog,v 1.100 2005/04/06 21:17:42 stpohle Exp $ + +Version 0.11.6.1 +================ + +- Ghost Player added. + Version 0.11.6 ============== diff --git a/configure.in b/configure.in index afc0809..dcb5620 100644 --- a/configure.in +++ b/configure.in @@ -5,7 +5,7 @@ dnl Please disable it in the Anjuta project configuration AC_INIT(configure.in) AC_CANONICAL_TARGET -AM_INIT_AUTOMAKE(bomberclone, 0.11.6) +AM_INIT_AUTOMAKE(bomberclone, 0.11.6.1) AM_CONFIG_HEADER(config.h) diff --git a/include/gfx.h b/include/gfx.h index 4949074..6d7ab95 100644 --- a/include/gfx.h +++ b/include/gfx.h @@ -1,4 +1,4 @@ -/* $Id: gfx.h,v 1.8 2004/09/26 02:28:05 stpohle Exp $ */ +/* $Id: gfx.h,v 1.9 2005/04/06 21:17:48 stpohle Exp $ */ #ifndef _GFX_H_ #define _GFX_H_ @@ -60,6 +60,8 @@ struct __gfx { _gfxani bomb; // bomb animation _gfxani ill; // sick animation above the player _gfxani dead; // load the dead player animation + SDL_Surface *ghost; // gfx of the ghost player. + SDL_Surface *ghost_small; // small ghost player _gfxani respawn; // respawn image _gfxani menuselect; // The Menu Select GFX (the bomb ?) diff --git a/src/game.c b/src/game.c index bc06efa..e9e9e97 100644 --- a/src/game.c +++ b/src/game.c @@ -1,4 +1,4 @@ -/* $Id: game.c,v 1.107 2005/02/14 20:09:19 stpohle Exp $ +/* $Id: game.c,v 1.108 2005/04/06 21:17:48 stpohle Exp $ game.c - procedures for the game. */ #include @@ -629,8 +629,8 @@ void game_showresultteam (int pos_x, int pos_y, int pos_w, int pos_h) { for (t_nr = 0; t_nr < t_count; t_nr++) { sprintf (text, "%s Victorys %d (%d)", tdata[t_nr].team->name, tdata[t_nr].team->wins, tdata[t_nr].team->points); sx = (pos_w - strlen (text) * font[0].size.x) / 2; - font_gfxdrawbold (pos_x + sx, pos_y + sy+3, text, 0, COLOR_brown, 1, 1); - font_gfxdraw (pos_x + sx, pos_y + sy+3, text, 0, COLOR_yellow, 2); + font_gfxdrawbold (10+ pos_x + sx, pos_y + sy+3, text, 0, COLOR_brown, 1, 1); + font_gfxdraw (10+ pos_x + sx, pos_y + sy+3, text, 0, COLOR_yellow, 2); sy += SHOWRESULT_TEAMHEAD; dx = pos_w / p_x; sx = (dx - SHOWRESULT_TEAMPLAYERWIDTH)/2; @@ -651,8 +651,17 @@ void game_showresultteam (int pos_x, int pos_y, int pos_w, int pos_h) { src.y = 0; gfx_blit (tdata[t_nr].pl[p_nr]->gfx->small_image, &src, gfx.screen, &dest, 1); } + else { + dest.x = pos_x + x; + dest.y = pos_y + sy; + src.w = dest.w = gfx.ghost_small->w; + src.h = dest.h = gfx.ghost_small->h; + src.x = 0; + src.y = 0; + gfx_blit (gfx.ghost_small, &src, gfx.screen, &dest, 1); + } sprintf (text, "%s(%d/%d)", tdata[t_nr].pl[p_nr]->name, tdata[t_nr].pl[p_nr]->wins, tdata[t_nr].pl[p_nr]->points); - font_gfxdraw (pos_x + x + GFX_SMALLPLAYERIMGSIZE_X*2, pos_y + sy + 2, text, 0, 0, 2); + font_gfxdraw (10+ pos_x + x + GFX_SMALLPLAYERIMGSIZE_X*2, pos_y + sy + 2, text, 0, 0, 2); x += dx; col++; } @@ -718,14 +727,14 @@ void game_showresultnormal (int pos_x, int pos_y, int pos_w, int pos_h) { for (i = 1, p = 0; p < pl_cnt; p++) { if (PS_IS_used (pl[p]->state)) { if (PS_IS_alife (pl[p]->state)) { - font_gfxdrawbold (pos_x + x + GFX_MENUPLAYERIMGSIZE_X + 8, pos_y + y - 10, pl[p]->name, 0, COLOR_brown, 1, 1); - font_gfxdraw (pos_x + x + GFX_MENUPLAYERIMGSIZE_X + 8,pos_y + y - 10, pl[p]->name, 0, COLOR_yellow, 1); + font_gfxdrawbold (10+ pos_x + x + GFX_MENUPLAYERIMGSIZE_X + 8, pos_y + y - 10, pl[p]->name, 0, COLOR_brown, 1, 1); + font_gfxdraw (10+ pos_x + x + GFX_MENUPLAYERIMGSIZE_X + 8,pos_y + y - 10, pl[p]->name, 0, COLOR_yellow, 1); } else - font_gfxdraw (pos_x + x + GFX_MENUPLAYERIMGSIZE_X,pos_y + y - 10, pl[p]->name, 0, COLOR_gray, 1); + font_gfxdraw (10+ pos_x + x + GFX_MENUPLAYERIMGSIZE_X,pos_y + y - 10, pl[p]->name, 0, COLOR_gray, 1); sprintf (text, "%3d (%3d)", pl[p]->wins, pl[p]->points); - font_gfxdraw (pos_x + x + GFX_MENUPLAYERIMGSIZE_X, pos_y + y + 6, text, 0, 0, 1); + font_gfxdraw (10+ pos_x + x + GFX_MENUPLAYERIMGSIZE_X, pos_y + y + 6, text, 0, 0, 1); if (pl[p]->gfx != NULL) { dest.x = pos_x + x; @@ -736,6 +745,15 @@ void game_showresultnormal (int pos_x, int pos_y, int pos_w, int pos_h) { src.y = 0; gfx_blit (pl[p]->gfx->menu_image, &src, gfx.screen, &dest, 1); } + else { + dest.x = pos_x + x; + dest.y = pos_y + y - 16; + src.w = dest.w = gfx.ghost->w; + src.h = dest.h = gfx.ghost->h; + src.x = 0; + src.y = 0; + gfx_blit (gfx.ghost, &src, gfx.screen, &dest, 1); + } /* setup the new position */ y += (dy / pl_x); x += dx; diff --git a/src/gfx.c b/src/gfx.c index 0077f80..2869755 100644 --- a/src/gfx.c +++ b/src/gfx.c @@ -1,4 +1,4 @@ -/* $Id: gfx.c,v 1.38 2004/09/26 02:28:06 stpohle Exp $ */ +/* $Id: gfx.c,v 1.39 2005/04/06 21:17:48 stpohle Exp $ */ /* gfx.c */ #include "bomberclone.h" @@ -333,6 +333,20 @@ static void gfx_load_menusmall_players () { SDL_FreeSurface (img); } } + + /* load the ghost player */ + sprintf (filename, "%s/player/ghost.png", bman.datapath); + orgimg = IMG_Load (filename); + sfkt = (float)(((float)(GFX_MENUPLAYERIMGSIZE_X * 2)) / ((float)orgimg->h)); + gfx.ghost = scale_image (orgimg, (int)(((float)orgimg->w)*sfkt), GFX_MENUPLAYERIMGSIZE_X * 2); + if (gfx.ghost == NULL) { + printf ("Can't load image: %s\n", SDL_GetError ()); + exit (1); + } + sfkt = (float)(((float)(GFX_SMALLPLAYERIMGSIZE_X * 2)) / ((float)orgimg->h)); + gfx.ghost_small = scale_image (orgimg, (int)(((float)orgimg->w)*sfkt), GFX_SMALLPLAYERIMGSIZE_X * 2); + + SDL_FreeSurface (orgimg); } @@ -484,6 +498,11 @@ gfx_shutdown () } } + if (gfx.ghost != NULL) + SDL_FreeSurface (gfx.ghost); + if (gfx.ghost_small != NULL) + SDL_FreeSurface (gfx.ghost_small); + for (i = 0; i < FT_max; i++) if (gfx.menu_field[i] != NULL) { SDL_FreeSurface (gfx.menu_field[i]); gfx.menu_field[i] = NULL; diff --git a/src/packets.c b/src/packets.c index c4b4cac..cc6c259 100644 --- a/src/packets.c +++ b/src/packets.c @@ -151,8 +151,11 @@ do_joingame (struct pkg_joingame *p_jg, _net_addr * addr) team_choose (pl); } strncpy (pl->name, p_jg->name, LEN_PLAYERNAME); - pl->gfx_nr = -1; - pl->gfx = NULL; + pl->gfx_nr = s_random (gfx.player_gfx_count); + while (pl->gfx_nr >= gfx.player_gfx_count) { + pl->gfx_nr -= gfx.player_gfx_count; + } + pl->gfx = &gfx.players[pl->gfx_nr]; pl->state &= (0xFF - (PSF_alife + PSF_playing)); /* Reset the network data */