diff options
Diffstat (limited to 'blits.c')
-rw-r--r-- | blits.c | 138 |
1 files changed, 49 insertions, 89 deletions
@@ -21,20 +21,55 @@ void Fblitterennemis (SURFACES *surfaces, POSITIONS *positions,ENNEMIS ennemis[] SDL_Flip (surfaces->Pecran); } -void Fblitterpersos (SURFACES *surfaces, POSITIONS *positions, PERSONNAGES persos[]) +static void blit_chr_infos(SURFACES *surfaces, struct character_t *chr) { - int i; - for(i=0;i<3;i++) - { - SDL_BlitSurface(surfaces->Tperso[i], NULL, surfaces->Pecran, &positions->Vpositionpersos[i]); + TTF_Font *police=NULL; + SDL_Color fg={132,215,107,0},bg={100,0,0,0}; + char string[256]; - if(persos[i].etat==MORT) - { + SDL_Surface *surf_hp; + SDL_Surface *surf_mp; + + police=TTF_OpenFont("TIMESBI.TTF",18); + sprintf(string, "PV %d/%d ", chr->hp, chr->max_hp); + surf_hp = TTF_RenderText_Shaded(police, string, fg, bg); + sprintf(string, "PM %d/%d ", chr->mp, chr->max_mp); + surf_mp = TTF_RenderText_Shaded(police, string, fg, bg); + + chr->pos_hp.x = chr->pos.x + chr->def_surf->w / 2 - surf_hp->w / 2; + chr->pos_mp.x = chr->pos.x + chr->def_surf->w / 2 - surf_mp->w / 2; + chr->pos_hp.y = chr->pos.y + chr->def_surf->h - surf_hp->h - surf_mp->h; + chr->pos_mp.y = chr->pos_hp.y + surf_mp->h; + + SDL_BlitSurface(surf_hp, NULL, surfaces->Pecran, &chr->pos_hp); + SDL_BlitSurface(surf_mp, NULL, surfaces->Pecran, &chr->pos_mp); + + chr->pos_hp.w = surf_hp->w; + chr->pos_hp.h = surf_hp->h; + chr->pos_mp.w = surf_mp->w; + chr->pos_mp.h = surf_mp->h; + + SDL_FreeSurface(surf_hp); + SDL_FreeSurface(surf_mp); + + TTF_CloseFont(police); +} + +void blit_ally_team(SURFACES *surfaces, POSITIONS *positions, struct team_t *team) +{ + for (int i = 0; i < team->chr_cnt; i++) { + struct character_t *chr = &team->chrs[i]; + + /* TODO blit either default or red surf */ + SDL_BlitSurface(chr->def_surf, NULL, surfaces->Pecran, &positions->Vpositionpersos[i]); + + + if (!chr->alive) { positions->Vpositionmort.x=positions->Vpositionpersos[i].x+surfaces->Tperso[i]->w/2-surfaces->Pmort->w/2; positions->Vpositionmort.y=positions->Vpositionpersos[i].y+surfaces->Tperso[i]->h/2-surfaces->Pmort->h/2; SDL_BlitSurface(surfaces->Pmort,NULL,surfaces->Pecran,&positions->Vpositionmort); } - Fblitterpmpvpersos(surfaces,positions,persos,i); + blit_chr_infos(surfaces, chr); } } @@ -68,11 +103,8 @@ void Fchangercurseurennemis (SURFACES *surfaces, POSITIONS *positions,int select TTF_CloseFont(police); } -void Fchangercurseurpersos (SURFACES *surfaces, POSITIONS *positions,int selection,PERSONNAGES persos[]) +void Fchangercurseurpersos (SURFACES *surfaces, POSITIONS *positions,int selection) { - /* TODO undestand if this is needed or not */ - (void) persos; - SDL_BlitSurface (surfaces->Pfondjeu,&positions->Vpositioncurseurallies,surfaces->Pecran,&positions->Vpositioncurseurallies); SDL_Flip (surfaces->Pecran); SELECTION (0,ALLIE) @@ -179,7 +211,7 @@ void Fchangeractionselectionnee(SURFACES *surfaces, POSITIONS *positions,int sel TTF_CloseFont (police); } -void Fafficherdegats (SURFACES *surfaces, POSITIONS *positions, int degats,int clan, int cible,PERSONNAGES persos[]) +void Fafficherdegats (SURFACES *surfaces, POSITIONS *positions, int degats,int clan, int cible, struct team_t *ally) { char chaine[10]; TTF_Font *police = NULL; @@ -204,7 +236,7 @@ void Fafficherdegats (SURFACES *surfaces, POSITIONS *positions, int degats,int c positions->Vpositiondegats.x=positions->Vpositionpersos[cible].x+surfaces->Tperso[cible]->w+30; positions->Vpositiondegats.y=positions->Vpositionpersos[cible].y+surfaces->Tperso[cible]->h/2-surfaces->Pnbdegats->h/2; SDL_BlitSurface(surfaces->Pfondjeu,&positions->Vpositionpvpersos[cible],surfaces->Pecran,&positions->Vpositionpvpersos[cible]); - Fblitterpersos(surfaces,positions,persos); + blit_ally_team(surfaces, positions, ally); } positions->Vpositiondegats.w=surfaces->Pnbdegats->w; positions->Vpositiondegats.h=surfaces->Pnbdegats->h; @@ -213,12 +245,11 @@ void Fafficherdegats (SURFACES *surfaces, POSITIONS *positions, int degats,int c TTF_CloseFont (police); } -void Faffichersoins (SURFACES *surfaces, POSITIONS *positions, int degats,int clan, int cible,PERSONNAGES persos[]) +void Faffichersoins (SURFACES *surfaces, POSITIONS *positions, int degats,int clan, int cible, struct team_t *ally) { char chaine[10]; - - /* TODO understand if this is needed or not */ - (void) persos; + + (void) ally; TTF_Font *police = NULL; SDL_Color fg = {80,255,80,0}; @@ -323,30 +354,6 @@ void Fblitterpmcible (SURFACES *surfaces,POSITIONS *positions,ENNEMIS ennemis[], TTF_CloseFont (police); } -void Fblitterpmpvpersos(SURFACES *surfaces,POSITIONS *positions,PERSONNAGES persos[],int selection) -{ - TTF_Font *police=NULL; - SDL_Color fg={132,215,107,0},bg={100,0,0,0}; - char chaine[2][50]; - police=TTF_OpenFont("TIMESBI.TTF",18); - sprintf(chaine[0],"PV %d/%d ",persos[selection].pv,persos[selection].pvinitiaux); - surfaces->Ppvpersos=TTF_RenderText_Shaded(police,chaine[0],fg,bg); - sprintf(chaine[1],"PM %d/%d ",persos[selection].pm,persos[selection].pminitiaux); - surfaces->Ppmpersos=TTF_RenderText_Shaded(police,chaine[1],fg,bg); - positions->Vpositionpvpersos[selection].x=(positions->Vpositionpersos[selection].x+surfaces->Tperso[selection]->w/2-surfaces->Ppvpersos->w/2); - positions->Vpositionpmpersos[selection].x=(positions->Vpositionpersos[selection].x+surfaces->Tperso[selection]->w/2-surfaces->Ppmpersos->w/2); - positions->Vpositionpvpersos[selection].y=(positions->Vpositionpersos[selection].y+surfaces->Tperso[selection]->h-surfaces->Ppvpersos->h-surfaces->Ppmpersos->h); - positions->Vpositionpmpersos[selection].y=(positions->Vpositionpersos[selection].y+surfaces->Tperso[selection]->h-surfaces->Ppmpersos->h); - SDL_BlitSurface(surfaces->Ppvpersos,NULL,surfaces->Pecran,&positions->Vpositionpvpersos[selection]); - SDL_BlitSurface(surfaces->Ppmpersos,NULL,surfaces->Pecran,&positions->Vpositionpmpersos[selection]); - positions->Vpositionpvpersos[selection].w=surfaces->Ppvpersos->w; - positions->Vpositionpvpersos[selection].h=surfaces->Ppvpersos->h; - positions->Vpositionpmpersos[selection].w=surfaces->Ppmpersos->w; - positions->Vpositionpmpersos[selection].h=surfaces->Ppmpersos->h; - - TTF_CloseFont(police); -} - void Fblitterfond(SURFACES* surfaces) { SDL_Rect position; @@ -356,50 +363,3 @@ void Fblitterfond(SURFACES* surfaces) SDL_BlitSurface(surfaces->Pfondjeu,NULL,surfaces->Pecran,&position); SDL_Flip(surfaces->Pecran); } - -void highlight_current_character(SURFACES* surfaces, PERSONNAGES persos[], int character_idx) -{ - switch (persos[character_idx].classe) { - case PALADIN: - surfaces->Tperso[character_idx] = surfaces->red_paladin; - break; - case PRETRE: - surfaces->Tperso[character_idx] = surfaces->red_priest; - break; - case VOLEUR: - surfaces->Tperso[character_idx] = surfaces->red_thief; - break; - default: - abort(); - } -} - -void unhighlight_prev_character(SURFACES *surfaces, PERSONNAGES persos[], int character_idx) -{ - switch (persos[character_idx].classe) { - case PALADIN: - surfaces->Tperso[character_idx] = surfaces->Ppaladin; - break; - case PRETRE: - surfaces->Tperso[character_idx] = surfaces->Ppretre; - break; - case VOLEUR: - surfaces->Tperso[character_idx] = surfaces->Pvoleur; - break; - default: - abort(); - } -} - -void Fblitcoloredselection (SURFACES surfaces[],POSITIONS positions[],int Vtourallie,PERSONNAGES persos[]) -{ - SDL_BlitSurface(surfaces->Tperso[Vtourallie],NULL,surfaces->Pecran,&positions->Vpositionpersos[Vtourallie]); - Fblitterpmpvpersos(surfaces,positions,persos,Vtourallie); - SDL_Flip(surfaces->Pecran); -} - - - - - - |