diff --git a/src/affichage.c b/src/affichage.c index f98560c3001f8f369da962553e7807fad301e4b3..6762c65f356779a0cadeedb6d5de2e924f97655e 100644 --- a/src/affichage.c +++ b/src/affichage.c @@ -337,8 +337,8 @@ int saisie_noms_joueurs() */ int affichage_ecran_accueil() { - ajouterUnJoueur(nom_1,&etat); ajouterUnJoueur(nom_2,&etat); + ajouterUnJoueur(nom_1,&etat); etat=LANCEMENT; SDL_Surface* ecran = SDL_SetVideoMode(LARGEUR_CARTE*(LARGEUR_CASE+1), HAUTEUR_CARTE*(HAUTEUR_CASE+2), 32, SDL_HWSURFACE|SDL_DOUBLEBUF); SDL_WM_SetCaption("Elder Internal Ignition",NULL); @@ -667,10 +667,8 @@ int affichage_menu_configuration() /*! - * \fn int affichage_carte(char** Map) - * \brief fonction qui gère l'affichage pendant la partie - * - * \param la carte au format texte (une lettre = une case) + * \fn int affichage_carte() + * \brief fonction qui gère l'affichage pendant la partie (carte, personnages, PV, etc) */ int affichage_carte() @@ -682,13 +680,13 @@ 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]; SDL_Rect Position_Perso[NB_PERSO*NB_JOUEURS]; SDL_Rect Position_Case_brillante; + SDL_Surface* perso; //surfaces affichees sur le cote SDL_Surface* PV = NULL; SDL_Surface* mana = NULL; SDL_Surface* texte = NULL; @@ -696,13 +694,13 @@ int affichage_carte() SDL_Surface* bouton1 = NULL; SDL_Surface* bouton2 = NULL; SDL_Surface* personnage_numero = NULL; + SDL_Rect pos_perso; 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_personnage_numero; TTF_Font *vieille_police = NULL; @@ -716,7 +714,7 @@ int affichage_carte() police_arial=TTF_OpenFont("../resources/fonts/arial.ttf",22); texte= TTF_RenderText_Shaded(vieille_police, "Joueur actuel :", couleurBlanche,couleurNoire); - nom_joueur= TTF_RenderText_Shaded(vieille_police, nom_1, couleurBlanche, couleurNoire); + nom_joueur= TTF_RenderText_Shaded(vieille_police, obtenirNomJoueurCourant(), couleurBlanche, couleurNoire); bouton1= TTF_RenderText_Shaded(vieille_police, "Perso suivant", couleurDoree, couleurBleue); bouton2= TTF_RenderText_Shaded(vieille_police, "Joueur suivant", couleurDoree, couleurBleue); @@ -740,10 +738,8 @@ int affichage_carte() pos_PV.y=pos_nom_joueur.y+(2*nom_joueur->h); pos_mana.x=ecran->w-(LARGEUR_BORDURE+mana->w)/2.1; 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_personnage_numero.x=ecran->w-(LARGEUR_BORDURE+mana->w)/2.4; pos_personnage_numero.y=pos_perso.y+(2*PV->h); @@ -772,6 +768,8 @@ int affichage_carte() SDL_SetColorKey( persos[i], SDL_SRCCOLORKEY, SDL_MapRGB( persos[i]->format, 0, 0, 255)); } + perso=persos[perso_actuel-1]; + perso_select = SDL_LoadBMP("../resources/Skins/guerrier_select.bmp"); if (!perso_select) { @@ -787,6 +785,7 @@ int affichage_carte() return 1; } SDL_SetColorKey(Case_brillante, SDL_SRCCOLORKEY, SDL_MapRGB(Case_brillante->format, 0, 0, 255)); + for(j=0; j<HAUTEUR_CARTE; j++) { for(i=0; i<LARGEUR_CARTE; i+=2) @@ -802,16 +801,6 @@ 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); @@ -836,14 +825,7 @@ int affichage_carte() sprintf(buffer_PV, "Personnage %d", perso_actuel-NB_PERSO); personnage_numero=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)); + perso=persos[perso_actuel-1]; } if(event.button.y>pos_bouton2.y&&event.button.y<pos_bouton2.y+bouton2->h&&event.button.x>LARGEUR_CARTE*LARGEUR_CASE) { @@ -863,14 +845,7 @@ int affichage_carte() sprintf(buffer_PV, "Personnage %d", perso_actuel-NB_PERSO); personnage_numero=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)); + perso=persos[perso_actuel-1]; } if(event.button.x<LARGEUR_CARTE*LARGEUR_CASE) { @@ -929,7 +904,7 @@ 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,NULL,ecran,&pos_perso); SDL_BlitSurface(personnage_numero,NULL,ecran,&pos_personnage_numero); SDL_Flip(ecran); @@ -951,10 +926,14 @@ int affichage_carte() SDL_FreeSurface(texte); SDL_FreeSurface(mana); SDL_FreeSurface(nom_joueur); + SDL_FreeSurface(perso); SDL_FreeSurface(bouton1); SDL_FreeSurface(bouton2); SDL_FreeSurface(PV); + SDL_FreeSurface(ecran); + SDL_FreeSurface(personnage_numero); TTF_CloseFont(vieille_police); + TTF_CloseFont(police_arial); etat=FERMER; return 0;