Skip to content
Snippets Groups Projects
Commit 1e13a4ec authored by Lénaïg Le Moigne's avatar Lénaïg Le Moigne
Browse files

On peut voir l'image du personnage qui est en train de jouer.

parent 607c2988
No related branches found
No related tags found
No related merge requests found
Pipeline #
......@@ -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];
......@@ -679,6 +685,7 @@ int affichage_carte()
SDL_Rect pos_nom_joueur;
SDL_Rect pos_bouton1;
SDL_Rect pos_bouton2;
SDL_Rect pos_perso;
TTF_Font *vieille_police = NULL;
SDL_Color couleurNoire = {0, 0, 0};
SDL_Color couleurBlanche = {255, 255, 255};
......@@ -711,6 +718,9 @@ 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);
for(i=0; i<LARGEUR_CARTE; i++)
{
for(j=0; j<HAUTEUR_CARTE; j++)
......@@ -726,15 +736,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 +775,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 +795,23 @@ 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);
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 +820,16 @@ 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);
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 +850,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 +885,20 @@ 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_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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment