diff --git a/src/affichage.c b/src/affichage.c index 4c64c574a92d91266c64dcdab868ce0ab4cc3cff..3697bb174483a1ed381b45bd64a29821ece29563 100644 --- a/src/affichage.c +++ b/src/affichage.c @@ -65,15 +65,17 @@ int main_affichage() return 0; } -void perso_suivant(int *numPerso){ - if (*numPerso==NB_PERSO) *numPerso=1; - else if (*numPerso==NB_PERSO*2) *numPerso=NB_PERSO+1; - else *numPerso++; +int perso_suivant(int numPerso){ + if (numPerso==NB_PERSO) numPerso=1; + else if (numPerso==NB_PERSO*2) numPerso=NB_PERSO+1; + else numPerso++; + return numPerso; } -void actualiser_num_perso(int *numPerso){ - if (*numPerso<=NB_PERSO) *numPerso=NB_PERSO+1; - else *numPerso=1; +int actualiser_num_perso(int numPerso){ + if (numPerso<=NB_PERSO) numPerso=NB_PERSO+1; + else numPerso=1; + return numPerso; } /*! @@ -654,17 +656,17 @@ int affichage_carte() { int i,j,y=0; int x=0; - int perso_select=1; + int perso_actuel=1; SDL_Event event; SDL_Surface* ecran=SDL_SetVideoMode(LARGEUR_CARTE*(LARGEUR_CASE)+LARGEUR_BORDURE, HAUTEUR_CARTE*(HAUTEUR_CASE+2), 32, SDL_HWSURFACE|SDL_DOUBLEBUF);; SDL_Surface* cases[HAUTEUR_CARTE][LARGEUR_CARTE]; SDL_Surface* persos[NB_PERSO*NB_JOUEURS]; SDL_Surface* Case_brillante=NULL; - SDL_Surface* Guerrier_select=NULL; + SDL_Surface* perso_select=NULL; SDL_Rect Position_Case[HAUTEUR_CARTE][LARGEUR_CARTE]; SDL_Rect Position_Perso[NB_PERSO*NB_JOUEURS]; SDL_Rect Position_Case_brillante; - SDL_Rect Position_Guerrier_select; + SDL_Rect position_perso_select; SDL_Surface* PV = NULL; SDL_Surface* texte = NULL; @@ -688,9 +690,10 @@ int affichage_carte() nom_joueur= TTF_RenderText_Shaded(vieille_police, nom_1, couleurBlanche, couleurNoire); bouton1= TTF_RenderText_Shaded(vieille_police, "Perso suivant", couleurDoree, couleurBleue); bouton2= TTF_RenderText_Shaded(vieille_police, "Joueur suivant", couleurDoree, couleurBleue); - /*char* buffer_PV; - sprintf(buffer_PV, "%d/%d", obtenirPVPersonnage(perso_select),obtenirPVMaxPersonnage(perso_select)); - PV=TTF_RenderText_Shaded(vieille_police, buffer_PV, couleurBlanche, couleurNoire);*/ + + char buffer_PV[9]; + sprintf(buffer_PV, "%d/%d", obtenirPVPersonnage(perso_actuel),obtenirPVMaxPersonnage(perso_actuel)); + PV=TTF_RenderText_Shaded(vieille_police, buffer_PV, couleurBlanche, couleurNoire); pos_texte.x=ecran->w-(LARGEUR_BORDURE+texte->w)/2; pos_texte.y=20; @@ -700,8 +703,8 @@ int affichage_carte() pos_bouton2.y=ecran->h-bouton2->h-40; pos_bouton1.x=ecran->w-(LARGEUR_BORDURE+bouton1->w)/2; pos_bouton1.y=pos_bouton2.y-(2*bouton2->h); - /*pos_PV.x=ecran->w-(LARGEUR_BORDURE+PV->w)/2; - pos_PV.y=pos_nom_joueur.y+(2*nom_joueur->h);*/ + pos_PV.x=ecran->w-(LARGEUR_BORDURE+PV->w)/2; + pos_PV.y=pos_nom_joueur.y+(2*nom_joueur->h); for(i=0; i<LARGEUR_CARTE; i++) { @@ -728,13 +731,13 @@ int affichage_carte() SDL_SetColorKey( persos[i], SDL_SRCCOLORKEY, SDL_MapRGB( persos[i]->format, 0, 0, 255)); } - Guerrier_select = SDL_LoadBMP("../resources/Skins/guerrier_select.bmp"); - if (!Guerrier_select) + perso_select = SDL_LoadBMP("../resources/Skins/guerrier_select.bmp"); + if (!perso_select) { printf("Unable to load bitmap: %s\n", SDL_GetError()); return 1; } - SDL_SetColorKey(Guerrier_select, SDL_SRCCOLORKEY, SDL_MapRGB(Guerrier_select->format, 0, 0, 255)); + SDL_SetColorKey(perso_select, SDL_SRCCOLORKEY, SDL_MapRGB(perso_select->format, 0, 0, 255)); Case_brillante = SDL_LoadBMP("../resources/Skins/case_brillante.bmp"); if (!Case_brillante) @@ -767,12 +770,17 @@ int affichage_carte() break; case SDL_MOUSEBUTTONDOWN: if(event.button.y>pos_bouton1.y&&event.button.y<pos_bouton1.y+bouton1->h){ - perso_suivant(&perso_select); + perso_actuel=perso_suivant(perso_actuel); + sprintf(buffer_PV, "%d/%d", obtenirPVPersonnage(perso_actuel),obtenirPVMaxPersonnage(perso_actuel)); + PV=TTF_RenderText_Shaded(vieille_police, buffer_PV, couleurBlanche, couleurNoire); } if(event.button.y>pos_bouton2.y&&event.button.y<pos_bouton2.y+bouton2->h){ - //fin_du_tour(); - //nom_joueur= TTF_RenderText_Shaded(vieille_police, obtenirNomJoueur(), couleurBlanche, couleurNoire); - actualiser_num_perso(&perso_select); + finDuTour(); + debutDuTour(); + nom_joueur= TTF_RenderText_Shaded(vieille_police, obtenirNomJoueurCourant(), couleurBlanche, couleurNoire); + actualiser_num_perso(perso_actuel); + sprintf(buffer_PV, "%d/%d", obtenirPVPersonnage(perso_actuel),obtenirPVMaxPersonnage(perso_actuel)); + PV=TTF_RenderText_Shaded(vieille_police, buffer_PV, couleurBlanche, couleurNoire); } if(event.button.x<LARGEUR_CARTE*LARGEUR_CASE){ //deplacement_personnage(event.button.x,event.button.y); @@ -827,7 +835,7 @@ int affichage_carte() } /*SDL_BlitSurface(Guerrier_select,NULL,ecran,&Position_Guerrier_select);*/ SDL_BlitSurface(Case_brillante,NULL,ecran,&Position_Case_brillante); - //SDL_BlitSurface(PV,NULL,ecran,&pos_PV); + SDL_BlitSurface(PV,NULL,ecran,&pos_PV); SDL_BlitSurface(texte,NULL,ecran,&pos_texte); SDL_BlitSurface(nom_joueur,NULL,ecran,&pos_nom_joueur); SDL_BlitSurface(bouton1,NULL,ecran,&pos_bouton1); @@ -845,12 +853,12 @@ int affichage_carte() SDL_FreeSurface(persos[i]); } SDL_FreeSurface(Case_brillante); - SDL_FreeSurface(Guerrier_select); + SDL_FreeSurface(perso_select); SDL_FreeSurface(texte); SDL_FreeSurface(nom_joueur); SDL_FreeSurface(bouton1); SDL_FreeSurface(bouton2); - //SDL_FreeSurface(PV); + SDL_FreeSurface(PV); TTF_CloseFont(vieille_police); etat=FERMER;