diff --git a/resources/Thumbs.db b/resources/Thumbs.db new file mode 100644 index 0000000000000000000000000000000000000000..d2f48f0b750c8d1754f3df2c9a1b99ac5c2eba23 Binary files /dev/null and b/resources/Thumbs.db differ diff --git a/resources/normal2_brillant.bmp b/resources/normal2_brillant.bmp new file mode 100644 index 0000000000000000000000000000000000000000..93b0bdfe431857f7793bc045fdc98a0d4844874a Binary files /dev/null and b/resources/normal2_brillant.bmp differ diff --git a/src/SDL.c b/src/SDL.c index 684eb41b0cbe48b0c4edec7c1cb37959bfc97655..2aeca95df54f56d8e2245197aedf4195e71b39e9 100644 --- a/src/SDL.c +++ b/src/SDL.c @@ -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 événement de type "touche pressée" */ 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; diff --git a/src/controleurSDL.c b/src/controleurSDL.c index c92b8807d0e9a128c17e4bb5c83ca9cd9a9d2b4a..fb1f44d96a9ea9b05ca61a269dfd197e68ca008e 100644 --- a/src/controleurSDL.c +++ b/src/controleurSDL.c @@ -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); +} diff --git a/src/controleurSDL.h b/src/controleurSDL.h index 71d6d9c3db97845480f8d000477a39272c5083ae..fcd7168f2f517740e0f5ec921a162a147ad52344 100644 --- a/src/controleurSDL.h +++ b/src/controleurSDL.h @@ -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