From 5b67651831ad9b160b41990288c938c7a05c1db1 Mon Sep 17 00:00:00 2001 From: oroborus Date: Wed, 13 Aug 2008 13:54:09 +0000 Subject: - upravene indexovanie v index.c a space.c ktore indexovanie pouziva git-svn-id: http://opensvn.csie.org/tuxanci_ng@194 0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e --- src/client/interface.c | 7 ++-- src/client/panel.c | 112 +++++++++++++++++++++---------------------------- src/client/panel.h | 2 +- 3 files changed, 53 insertions(+), 68 deletions(-) (limited to 'src/client') diff --git a/src/client/interface.c b/src/client/interface.c index 37aa361..b697524 100755 --- a/src/client/interface.c +++ b/src/client/interface.c @@ -16,7 +16,7 @@ static SDL_Surface *screen; static SDL_TimerID timer; // window flags -static Uint32 g_win_flags = SDL_HWSURFACE|SDL_DOUBLEBUF; +static Uint32 g_win_flags = SDL_SWSURFACE|SDL_DOUBLEBUF|SDL_ANYFORMAT; static bool_t isInterfaceInit = FALSE; @@ -70,9 +70,9 @@ int initSDL() screen->format->BitsPerPixel, screen->format->Rmask, screen->format->Gmask, screen->format->Bmask, screen->format->Amask); - - memset(my_surface->pixels, 128, 200); */ + //memset(my_surface->pixels, 128, 200); + if (screen == NULL ) { fprintf(stderr, "%s\n", SDL_GetError()); @@ -106,6 +106,7 @@ void interfaceRefresh() //drawImage(my_surface, 200, 100, 0, 0, 200, 200); SDL_Flip(screen); + //SDL_UpdateRect(screen, 400, 0, 400, 600); } int toggleFullscreen() diff --git a/src/client/panel.c b/src/client/panel.c index f63e481..b84cdfb 100644 --- a/src/client/panel.c +++ b/src/client/panel.c @@ -51,36 +51,24 @@ void initPanel() isPanelInit = TRUE; } -static void setScoreline(list_t *listTux, char *str) -{ - tux_t *thisTux; - int i; - - assert( listTux != NULL ); - assert( str != NULL ); - - strcpy(str, ""); - - for( i = 0 ; i < listTux->count ; i++ ) - { - char num[STR_SIZE]; - - thisTux = (tux_t *)listTux->list[i]; - assert( thisTux != NULL ); - - sprintf(num, "%s%d", ( i == 0 ? "" : " : " ), thisTux->score); - strcat(str, num); - } -} - -static void drawScore(list_t *listTux) +static void drawScore(tux_t *tux_right, tux_t *tux_left) { char strScoreLine[STR_SIZE]; int w, h; - assert( listTux != NULL ); + if( tux_right != NULL && tux_left != NULL ) + { + sprintf(strScoreLine, "%d : %d", tux_right->score, tux_left->score); + } + else if( tux_right != NULL ) + { + sprintf(strScoreLine, "%d", tux_right->score); + } + else if( tux_left != NULL ) + { + sprintf(strScoreLine, "%d", tux_left->score); + } - setScoreline(listTux, strScoreLine); getTextSize(strScoreLine, &w , &h); drawFont(strScoreLine, PANEL_SCORE_LOCATION_X, PANEL_SCORE_LOCATION_Y, COLOR_WHITE); } @@ -137,56 +125,52 @@ static void drawGrafBonus(tux_t *tux,int x, int y) drawImage(g_bonus, x+1, y, 0, g_bonus->h/2, offset, g_bonus->h/2); } -void drawPanel(list_t *listTux) +static void drawTuxRight(tux_t *tux) { - int i; + if( tux == NULL ) + { + return; + } - assert( listTux != NULL ); + drawShotInfo(tux, PANEL_LOCATION_X+740, PANEL_LOCATION_Y+34); + drawGunInfo(tux, PANEL_LOCATION_X+620, PANEL_LOCATION_Y+30); - drawImage(g_panel, PANEL_LOCATION_X, PANEL_LOCATION_Y, 0, 0, g_panel->w, g_panel->h); - drawScore(listTux); + if( tux->bonus != BONUS_NONE ) + { + drawGrafBonus(tux, PANEL_LOCATION_X+460, PANEL_LOCATION_Y+50); + drawBonusInfo(tux, PANEL_LOCATION_X+460, PANEL_LOCATION_Y+30); + } +} - if( isRecivedNewMsg() ) +static void drawTuxLeft(tux_t *tux) +{ + if( tux == NULL ) { - drawFont("recived new msg", PANEL_LOCATION_X, PANEL_LOCATION_Y, COLOR_WHITE); + return; } - for( i = 0 ; i < listTux->count ; i++ ) + drawShotInfo(tux, PANEL_LOCATION_X+8, PANEL_LOCATION_Y+34); + drawGunInfo(tux, PANEL_LOCATION_X+130, PANEL_LOCATION_Y+30); + + if( tux->bonus != BONUS_NONE ) { - tux_t *thisTux; - int x, y; - - thisTux = (tux_t *)listTux->list[i]; - assert( thisTux != NULL ); + drawGrafBonus(tux, PANEL_LOCATION_X+200, PANEL_LOCATION_Y+50); + drawBonusInfo(tux, PANEL_LOCATION_X+200, PANEL_LOCATION_Y+30); + } +} - x = PANEL_LOCATION_X; - y = PANEL_LOCATION_Y; +void drawPanel(tux_t *tux_right, tux_t *tux_left) +{ + drawImage(g_panel, PANEL_LOCATION_X, PANEL_LOCATION_Y, 0, 0, g_panel->w, g_panel->h); + drawScore(tux_right, tux_left); - switch( i ) - { - case 0 : - drawShotInfo(thisTux, x+8, y+34); - drawGunInfo(thisTux, x+130, y+30); - - if( thisTux->bonus != BONUS_NONE ) - { - drawGrafBonus(thisTux,x+200, y+50); - drawBonusInfo(thisTux,x+200, y+30); - } - break; - - case 1 : - drawShotInfo(thisTux, x+740, y+34); - drawGunInfo(thisTux, x+620, y+30); - - if( thisTux->bonus != BONUS_NONE ) - { - drawGrafBonus(thisTux,x+460, y+50); - drawBonusInfo(thisTux,x+460, y+30); - } - break; - } + if( isRecivedNewMsg() ) + { + drawFont("recived new msg", PANEL_LOCATION_X, PANEL_LOCATION_Y, COLOR_WHITE); } + + drawTuxRight(tux_right); + drawTuxLeft(tux_left); } void quitPanel() diff --git a/src/client/panel.h b/src/client/panel.h index 4935c75..6eadd92 100644 --- a/src/client/panel.h +++ b/src/client/panel.h @@ -21,7 +21,7 @@ extern bool_t isPanelInicialized(); extern void initPanel(); -extern void drawPanel(list_t *listTux); +extern void drawPanel(tux_t *tux_right, tux_t *tux_left); extern void quitPanel(); #endif -- cgit v1.2.3