Skip to content
Snippets Groups Projects
Commit 75ffaf07 authored by Montjoie Henri's avatar Montjoie Henri
Browse files

ajout de la surbrillance

parent 4bf741ec
No related branches found
No related tags found
No related merge requests found
File added
resources/normal2_brillant.bmp

15.2 KiB

......@@ -23,8 +23,12 @@ int main_SDL()
SDL_Event event;
SDL_Surface* perso[NB_PERSO]={NULL};
SDL_Surface* Case=NULL;
SDL_Surface* Case_brillante=NULL;
SDL_Rect Position_Case[LARGEUR_CARTE*HAUTEUR_CARTE];
SDL_Rect Position_Perso[NB_PERSO];
SDL_Rect Position_Case_brillante;
int x_case_brillante;
int y_case_brillante;
int quitter=0;
if ( SDL_Init( SDL_INIT_VIDEO ) < 0 )
......@@ -57,6 +61,14 @@ int main_SDL()
}
SDL_SetColorKey(Case, SDL_SRCCOLORKEY, SDL_MapRGB(Case->format, 0, 0, 255));
Case_brillante = SDL_LoadBMP("../resources/normal2_brillant.bmp");
if (!Case_brillante)
{
printf("Unable to load bitmap: %s\n", SDL_GetError());
return 1;
}
SDL_SetColorKey(Case_brillante, SDL_SRCCOLORKEY, SDL_MapRGB(Case->format, 0, 0, 255));
for(i=0;i<LARGEUR_CARTE;i+=2)
{
for(j=0;j<HAUTEUR_CARTE;j++)
......@@ -87,6 +99,13 @@ int main_SDL()
case SDL_MOUSEBUTTONDOWN:
deplacement_personnage(0,event.button.x,event.button.y);
break;
case SDL_MOUSEMOTION:
if(event.motion.x<LARGEUR_CARTE*LARGEUR_CASE&&event.motion.y<HAUTEUR_CARTE*HAUTEUR_CASE)
{
x_case_brillante = get_position_case_x(deplacement_brillance(event.motion.x,event.motion.y));
y_case_brillante = get_position_case_y(deplacement_brillance(event.motion.x,event.motion.y));
}
break;
case SDL_KEYDOWN:/* Si c'est un vnement de type "touche presse" */
switch(event.key.keysym.sym){
case SDLK_ESCAPE:
......@@ -99,16 +118,20 @@ int main_SDL()
}
Position_Perso[0].x=get_position_perso_x(0);
Position_Perso[0].y=get_position_perso_y(0);
Position_Case_brillante.x=x_case_brillante;
Position_Case_brillante.y=y_case_brillante;
SDL_FillRect(ecran,NULL,SDL_MapRGB(ecran->format,0,0,0));
for(i=0;i<LARGEUR_CARTE*HAUTEUR_CARTE;i++)
{
SDL_BlitSurface(Case,NULL,ecran,&Position_Case[i]);
}
SDL_BlitSurface(Case_brillante,NULL,ecran,&Position_Case_brillante);
SDL_BlitSurface(perso[0],NULL,ecran,&Position_Perso[0]);
SDL_Flip(ecran);
}
quitter=0;
SDL_FreeSurface(Case);
SDL_FreeSurface(Case_brillante);
SDL_FreeSurface(perso[0]);
SDL_Quit();
return 0;
......
......@@ -95,4 +95,21 @@ int get_position_perso_y(int num)
return get_y(case_perso);
}
Case* deplacement_brillance(int x,int y)
{
if(x<LARGEUR_CARTE*LARGEUR_CASE&&y<HAUTEUR_CARTE*HAUTEUR_CASE)
{
return trouverCase(Carte_actuelle,x_case_cliquee(x,y),y_case_cliquee(x,y));
}
return NULL;
}
int get_position_case_y(Case * Case){
return get_y(Case);
}
int get_position_case_x(Case * Case)
{
return get_x(Case);
}
......@@ -23,6 +23,11 @@ int get_position_perso_y(int num);
void init_controleur();
Case* deplacement_brillance(int x,int y);
int get_position_case_y(Case * Case);
int get_position_case_x(Case * Case);
#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