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

Modifications permettant de sélectionner le personnage en jeu afin de le différencier des autres.

parent 8456b885
No related branches found
No related tags found
No related merge requests found
Pipeline #
resources/guerrier_select.bmp

15.2 KiB

...@@ -33,13 +33,17 @@ int main_SDL(char* Map) ...@@ -33,13 +33,17 @@ int main_SDL(char* Map)
SDL_Surface* bouton_continuer=NULL; SDL_Surface* bouton_continuer=NULL;
SDL_Surface* bouton_quitter=NULL; SDL_Surface* bouton_quitter=NULL;
SDL_Surface* Case_brillante=NULL; SDL_Surface* Case_brillante=NULL;
SDL_Surface* Guerrier_select=NULL;
SDL_Rect Position_Case[LARGEUR_CARTE*HAUTEUR_CARTE]; SDL_Rect Position_Case[LARGEUR_CARTE*HAUTEUR_CARTE];
SDL_Rect Position_Perso[NB_PERSO]; SDL_Rect Position_Perso[NB_PERSO];
SDL_Rect Position_Case_brillante; SDL_Rect Position_Case_brillante;
SDL_Rect Position_Guerrier_select;
SDL_Rect pos_bouton_continuer; SDL_Rect pos_bouton_continuer;
SDL_Rect pos_bouton_quitter; SDL_Rect pos_bouton_quitter;
int x_case_brillante; int x_case_brillante;
int y_case_brillante; int y_case_brillante;
int x_guerrier_select;
int y_guerrier_select;
int quitter=0; int quitter=0;
affichermenu=0; affichermenu=0;
...@@ -158,6 +162,14 @@ int main_SDL(char* Map) ...@@ -158,6 +162,14 @@ int main_SDL(char* Map)
} }
SDL_SetColorKey(Case_brillante, SDL_SRCCOLORKEY, SDL_MapRGB(Case_brillante->format, 0, 0, 255)); SDL_SetColorKey(Case_brillante, SDL_SRCCOLORKEY, SDL_MapRGB(Case_brillante->format, 0, 0, 255));
Guerrier_select = SDL_LoadBMP("../resources/guerrier_select.bmp");
if (!Guerrier_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));
for(i=0;i<LARGEUR_CARTE;i+=2) for(i=0;i<LARGEUR_CARTE;i+=2)
{ {
for(j=0;j<HAUTEUR_CARTE;j++) for(j=0;j<HAUTEUR_CARTE;j++)
...@@ -243,6 +255,8 @@ int main_SDL(char* Map) ...@@ -243,6 +255,8 @@ int main_SDL(char* Map)
} }
Position_Case_brillante.x=x_case_brillante; Position_Case_brillante.x=x_case_brillante;
Position_Case_brillante.y=y_case_brillante; Position_Case_brillante.y=y_case_brillante;
Position_Guerrier_select.x=x_guerrier_select;
Position_Guerrier_select.y=y_guerrier_select;
SDL_FillRect(ecran,NULL,SDL_MapRGB(ecran->format,0,0,0)); SDL_FillRect(ecran,NULL,SDL_MapRGB(ecran->format,0,0,0));
if(affichermenu==0) if(affichermenu==0)
{ {
...@@ -266,9 +280,12 @@ int main_SDL(char* Map) ...@@ -266,9 +280,12 @@ int main_SDL(char* Map)
} }
SDL_BlitSurface(Case_brillante,NULL,ecran,&Position_Case_brillante); SDL_BlitSurface(Case_brillante,NULL,ecran,&Position_Case_brillante);
SDL_BlitSurface(Guerrier_select,NULL,ecran,&Position_Guerrier_select);
for(i=0;i<NB_PERSO;i++) for(i=0;i<NB_PERSO;i++)
{ {
SDL_BlitSurface(guerrier,NULL,ecran,&Position_Perso[i]); SDL_BlitSurface(guerrier,NULL,ecran,&Position_Perso[i]);
x_guerrier_select = get_position_case_x(&Position_Perso[persoactuel()]);
y_guerrier_select = get_position_case_y(&Position_Perso[persoactuel()]);
} }
}else{ }else{
SDL_BlitSurface(bouton_continuer,NULL,ecran,&pos_bouton_continuer); SDL_BlitSurface(bouton_continuer,NULL,ecran,&pos_bouton_continuer);
...@@ -280,6 +297,7 @@ int main_SDL(char* Map) ...@@ -280,6 +297,7 @@ int main_SDL(char* Map)
quitter=0; quitter=0;
SDL_FreeSurface(guerrier); SDL_FreeSurface(guerrier);
SDL_FreeSurface(Case_brillante); SDL_FreeSurface(Case_brillante);
SDL_FreeSurface(Guerrier_select);
SDL_FreeSurface(plaine); SDL_FreeSurface(plaine);
SDL_FreeSurface(mage); SDL_FreeSurface(mage);
SDL_FreeSurface(voleur); SDL_FreeSurface(voleur);
......
...@@ -72,6 +72,10 @@ persosuivant(){ ...@@ -72,6 +72,10 @@ persosuivant(){
perso_actuel=0; perso_actuel=0;
} }
int persoactuel(){
return perso_actuel;
}
void deplacement_personnage(int x, int y) void deplacement_personnage(int x, int y)
{ {
if(x<LARGEUR_CARTE*LARGEUR_CASE&&y<HAUTEUR_CARTE*HAUTEUR_CASE) if(x<LARGEUR_CARTE*LARGEUR_CASE&&y<HAUTEUR_CARTE*HAUTEUR_CASE)
...@@ -112,6 +116,7 @@ Case* deplacement_brillance(int x,int y) ...@@ -112,6 +116,7 @@ Case* deplacement_brillance(int x,int y)
return NULL; return NULL;
} }
int get_position_case_y(Case * Case){ int get_position_case_y(Case * Case){
return get_y(Case); return get_y(Case);
} }
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#ifndef CONTROLEUR_SDL_H_INCLUDED #ifndef CONTROLEUR_SDL_H_INCLUDED
#define CONTROLEUR_SDL_H_INCLUDED #define CONTROLEUR_SDL_H_INCLUDED
int y_case_cliquee(int x_pixel, int y_pixel); int y_case_cliquee(int x_pixel, int y_pixel);
int x_case_cliquee(int x_pixel, int y_pixel); int x_case_cliquee(int x_pixel, int y_pixel);
...@@ -30,6 +31,8 @@ int get_position_case_y(Case * Case); ...@@ -30,6 +31,8 @@ int get_position_case_y(Case * Case);
int get_position_case_x(Case * Case); int get_position_case_x(Case * Case);
void persosuivant(); void persosuivant();
int persoactuel();
#endif
#endif
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