diff --git a/src/affichage.c b/src/affichage.c index 3c7f2775005b7b79414aa23ecdb8760e965c15a6..5132873bcd428377d683aa99be43384ebc761373 100644 --- a/src/affichage.c +++ b/src/affichage.c @@ -65,14 +65,16 @@ int main_affichage() return 0; } -int perso_suivant(int 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; } -int actualiser_num_perso(int numPerso){ +int actualiser_num_perso(int numPerso) +{ if (numPerso<=NB_PERSO) numPerso=NB_PERSO+1; else numPerso=1; return numPerso; @@ -556,9 +558,12 @@ int affichage_menu_configuration() else { c=afficher_cartes_personnalisees(); - if(c==-2){ + if(c==-2) + { c=-1; - }else{ + } + else + { selectionnerCarte(obtenirNomsCartes()[c]); } ecran = SDL_SetVideoMode(LARGEUR_CARTE*(LARGEUR_CASE+1), HAUTEUR_CARTE*(HAUTEUR_CASE+2), 32, SDL_HWSURFACE|SDL_DOUBLEBUF); @@ -661,6 +666,7 @@ int affichage_carte() 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* perso[NB_PERSO*NB_JOUEURS]; SDL_Surface* Case_brillante=NULL; SDL_Surface* perso_select=NULL; SDL_Rect Position_Case[HAUTEUR_CARTE][LARGEUR_CARTE]; @@ -673,30 +679,37 @@ int affichage_carte() SDL_Surface* nom_joueur = NULL; SDL_Surface* bouton1 = NULL; SDL_Surface* bouton2 = NULL; + SDL_Surface* perso_x = NULL; SDL_Rect pos_PV; SDL_Rect pos_mana; SDL_Rect pos_texte; SDL_Rect pos_nom_joueur; SDL_Rect pos_bouton1; SDL_Rect pos_bouton2; + SDL_Rect pos_perso; + SDL_Rect pos_perso_x; TTF_Font *vieille_police = NULL; + TTF_Font *police_arial = NULL; SDL_Color couleurNoire = {0, 0, 0}; SDL_Color couleurBlanche = {255, 255, 255}; SDL_Color couleurBleue = {10, 30, 80}; SDL_Color couleurDoree = {190, 190, 120}; vieille_police=TTF_OpenFont("../resources/fonts/OLDENGL.ttf",30); + police_arial=TTF_OpenFont("../resources/fonts/arial.ttf",26); texte= TTF_RenderText_Shaded(vieille_police, "Joueur actuel :", couleurBlanche,couleurNoire); 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[20]; + char buffer_PV[30]; sprintf(buffer_PV, "PV: %d/%d", obtenirPVPersonnage(perso_actuel),obtenirPVMaxPersonnage(perso_actuel)); PV=TTF_RenderText_Shaded(vieille_police, buffer_PV, couleurBlanche, couleurNoire); sprintf(buffer_PV, "mana: %d/%d", obtenirManaPersonnage(perso_actuel),obtenirManaMaxPersonnage(perso_actuel)); mana=TTF_RenderText_Shaded(vieille_police, buffer_PV, couleurBlanche, couleurNoire); + sprintf(buffer_PV, "Personnage %d", perso_actuel); + perso_x=TTF_RenderText_Shaded(police_arial, buffer_PV, couleurBlanche, couleurNoire); pos_texte.x=ecran->w-(LARGEUR_BORDURE+texte->w)/2; pos_texte.y=20; @@ -711,6 +724,12 @@ int affichage_carte() pos_mana.x=ecran->w-(LARGEUR_BORDURE+mana->w)/2; pos_mana.y=pos_PV.y+(2*PV->h); + pos_perso.x=ecran->w-(LARGEUR_BORDURE+texte->w)/2.7; + pos_perso.y=pos_mana.y+(2*mana->h); + + pos_perso_x.x=ecran->w-(LARGEUR_BORDURE+mana->w)/2.2; + pos_perso_x.y=pos_perso.y+(2*PV->h); + for(i=0; i<LARGEUR_CARTE; i++) { for(j=0; j<HAUTEUR_CARTE; j++) @@ -726,15 +745,15 @@ int affichage_carte() } for(i=0; i<NB_JOUEURS*NB_PERSO; i++) - { - persos[i]=SDL_LoadBMP(obtenirRessourcePersonnageNum(i+1)); - if (!persos[i]) - { - printf("Unable to load bitmap: %s\n", SDL_GetError()); - return 1; - } - SDL_SetColorKey( persos[i], SDL_SRCCOLORKEY, SDL_MapRGB( persos[i]->format, 0, 0, 255)); - } + { + persos[i]=SDL_LoadBMP(obtenirRessourcePersonnageNum(i+1)); + if (!persos[i]) + { + printf("Unable to load bitmap: %s\n", SDL_GetError()); + return 1; + } + SDL_SetColorKey( persos[i], SDL_SRCCOLORKEY, SDL_MapRGB( persos[i]->format, 0, 0, 255)); + } perso_select = SDL_LoadBMP("../resources/Skins/guerrier_select.bmp"); if (!perso_select) @@ -765,6 +784,17 @@ int affichage_carte() } } Position_Case_brillante=Position_Case[0][0]; + + + perso[perso_actuel]=SDL_LoadBMP(obtenirRessourcePersonnageNum(perso_actuel)); + if (!perso[perso_actuel]) + { + printf("Unable to load bitmap: %s\n", SDL_GetError()); + return 1; + } + SDL_SetColorKey( perso[perso_actuel], SDL_SRCCOLORKEY, SDL_MapRGB( perso[perso_actuel]->format, 0, 0, 255)); + + while(etat!=FERMER) { SDL_WaitEvent(&event); @@ -774,14 +804,30 @@ int affichage_carte() etat=FERMER; break; case SDL_MOUSEBUTTONDOWN: - if(event.button.y>pos_bouton1.y&&event.button.y<pos_bouton1.y+bouton1->h){ + if(event.button.y>pos_bouton1.y&&event.button.y<pos_bouton1.y+bouton1->h) + { perso_actuel=perso_suivant(perso_actuel); sprintf(buffer_PV, "PV: %d/%d", obtenirPVPersonnage(perso_actuel),obtenirPVMaxPersonnage(perso_actuel)); PV=TTF_RenderText_Shaded(vieille_police, buffer_PV, couleurBlanche, couleurNoire); sprintf(buffer_PV, "mana: %d/%d", obtenirManaPersonnage(perso_actuel),obtenirManaMaxPersonnage(perso_actuel)); mana=TTF_RenderText_Shaded(vieille_police, buffer_PV, couleurBlanche, couleurNoire); + if(perso_actuel <=3){ + sprintf(buffer_PV, "Personnage %d", perso_actuel); + perso_x=TTF_RenderText_Shaded(police_arial, buffer_PV, couleurBlanche, couleurNoire); + }else{ + sprintf(buffer_PV, "Personnage %d", perso_actuel-NB_PERSO); + perso_x=TTF_RenderText_Shaded(police_arial, buffer_PV, couleurBlanche, couleurNoire); + } + perso[perso_actuel]=SDL_LoadBMP(obtenirRessourcePersonnageNum(perso_actuel)); + if (!perso[perso_actuel]) + { + printf("Unable to load bitmap: %s\n", SDL_GetError()); + return 1; + } + SDL_SetColorKey( perso[perso_actuel], SDL_SRCCOLORKEY, SDL_MapRGB( perso[perso_actuel]->format, 0, 0, 255)); } - if(event.button.y>pos_bouton2.y&&event.button.y<pos_bouton2.y+bouton2->h){ + if(event.button.y>pos_bouton2.y&&event.button.y<pos_bouton2.y+bouton2->h) + { finDuTour(); debutDuTour(); nom_joueur= TTF_RenderText_Shaded(vieille_police, obtenirNomJoueurCourant(), couleurBlanche, couleurNoire); @@ -790,8 +836,24 @@ int affichage_carte() PV=TTF_RenderText_Shaded(vieille_police, buffer_PV, couleurBlanche, couleurNoire); sprintf(buffer_PV, "mana: %d/%d", obtenirManaPersonnage(perso_actuel),obtenirManaMaxPersonnage(perso_actuel)); mana=TTF_RenderText_Shaded(vieille_police, buffer_PV, couleurBlanche, couleurNoire); + if(perso_actuel <=3){ + sprintf(buffer_PV, "Personnage %d", perso_actuel); + perso_x=TTF_RenderText_Shaded(police_arial, buffer_PV, couleurBlanche, couleurNoire); + }else{ + sprintf(buffer_PV, "Personnage %d", perso_actuel-NB_PERSO); + perso_x=TTF_RenderText_Shaded(police_arial, buffer_PV, couleurBlanche, couleurNoire); + } + + perso[perso_actuel]=SDL_LoadBMP(obtenirRessourcePersonnageNum(perso_actuel)); + if (!perso[perso_actuel]) + { + printf("Unable to load bitmap: %s\n", SDL_GetError()); + return 1; + } + SDL_SetColorKey( perso[perso_actuel], SDL_SRCCOLORKEY, SDL_MapRGB( perso[perso_actuel]->format, 0, 0, 255)); } - if(event.button.x<LARGEUR_CARTE*LARGEUR_CASE){ + if(event.button.x<LARGEUR_CARTE*LARGEUR_CASE) + { //deplacement_personnage(event.button.x,event.button.y); } break; @@ -812,7 +874,7 @@ int affichage_carte() } break; } - for(i=0;i<NB_PERSO*NB_JOUEURS;i++) + for(i=0; i<NB_PERSO*NB_JOUEURS; i++) { obtenirPositionPersonnage(i+1, &x, &y); Position_Perso[i].x=x*LARGEUR_CASE; @@ -847,16 +909,21 @@ int affichage_carte() SDL_BlitSurface(bouton1,NULL,ecran,&pos_bouton1); SDL_BlitSurface(bouton2,NULL,ecran,&pos_bouton2); SDL_BlitSurface(mana,NULL,ecran,&pos_mana); + SDL_BlitSurface(perso[perso_actuel],NULL,ecran,&pos_perso); + SDL_BlitSurface(perso_x,NULL,ecran,&pos_perso_x); SDL_Flip(ecran); } - for(i=0;i<HAUTEUR_CARTE;i++){ - for(j=0;j<LARGEUR_CARTE;j++){ - SDL_FreeSurface(cases[i][j]); - } + for(i=0; i<HAUTEUR_CARTE; i++) + { + for(j=0; j<LARGEUR_CARTE; j++) + { + SDL_FreeSurface(cases[i][j]); + } } - for(i=0;i<NB_PERSO*NB_JOUEURS;i++){ + for(i=0; i<NB_PERSO*NB_JOUEURS; i++) + { SDL_FreeSurface(persos[i]); } SDL_FreeSurface(Case_brillante);