diff options
-rw-r--r-- | images/pretre.bmp (renamed from images/prêtre.bmp) | bin | 66018 -> 66018 bytes | |||
-rw-r--r-- | main.c | 58 | ||||
-rw-r--r-- | prototypes.h | 2 |
3 files changed, 38 insertions, 22 deletions
diff --git a/images/prêtre.bmp b/images/pretre.bmp Binary files differindex a6c4802..a6c4802 100644 --- a/images/prêtre.bmp +++ b/images/pretre.bmp @@ -45,7 +45,12 @@ int main (int argc, char *argv[]) TTF_Init(); SDL_WM_SetCaption ("WARCRAFT BATTLE",NULL); SDL_ShowCursor(SDL_DISABLE); - Fchargerimages (&surfaces); + if (Fchargerimages (&surfaces) < 0) { + TTF_Quit(); + SDL_Quit(); + return -1; + } + Finitialiserpositions (&positions,&surfaces); Fmenuprincipal (&surfaces, &positions); @@ -156,31 +161,40 @@ void Finitialiserpositions (POSITIONS *positions, SURFACES *surfaces) } } -void Fchargerimages (SURFACES *surfaces) +int Fchargerimages (SURFACES *surfaces) { +#define LOAD_IMAGE(_name, _path) \ + if ((surfaces->_name = IMG_Load(_path)) == NULL) { \ + fprintf(stderr, "Impossible d'ouvrir " _path); \ + return -1; \ + } + int i; - surfaces->Pgobelin = IMG_Load ("images/gobelin.bmp"); - surfaces->Ppaladin = IMG_Load ("images/paladin.bmp"); - surfaces->Ppretre = IMG_Load ("images/prêtre.bmp"); - surfaces->Pvoleur = IMG_Load ("images/voleur.bmp"); - surfaces->Pmenujouer = IMG_Load ("images/menu_principal/jouer.bmp"); - surfaces->Pmenuoptions = IMG_Load ("images/menu_principal/options.bmp"); - surfaces->Pmenuquitter = IMG_Load ("images/menu_principal/quitter.bmp"); - surfaces->Pchoixvoleur = IMG_Load ("images/menu_choix_classe/voleur.bmp"); - surfaces->Pchoixpretre = IMG_Load ("images/menu_choix_classe/pretre.bmp"); - surfaces->Pchoixpaladin = IMG_Load ("images/menu_choix_classe/paladin.bmp"); - surfaces->Pcurseurennemis = IMG_Load ("images/jeu/curseur.bmp"); - surfaces->Pcurseurallies = IMG_Load ("images/jeu/curseurpersos.bmp"); - surfaces->Pcadrecible = IMG_Load ("images/jeu/cadre_cible.bmp"); - surfaces->Pactive = IMG_Load ("images/jeu/active.bmp"); - surfaces->Pdesactive = IMG_Load ("images/jeu/desactive.bmp"); - surfaces->Pcadreactions = IMG_Load ("images/jeu/cadre_actions.bmp"); - surfaces->Pactionselectionnee=IMG_Load ("images/jeu/cadre_actions_select.bmp"); - surfaces->Pactiondesactivee=IMG_Load("images/jeu/cadre_actions_unactive.bmp"); - surfaces->Pmort=IMG_Load("images/jeu/mort.bmp"); + + LOAD_IMAGE(Pgobelin, "images/gobelin.bmp"); + LOAD_IMAGE(Ppaladin, "images/paladin.bmp"); + LOAD_IMAGE(Ppretre, "images/pretre.bmp"); + LOAD_IMAGE(Pvoleur, "images/voleur.bmp"); + LOAD_IMAGE(Pmenujouer, "images/menu_principal/jouer.bmp"); + LOAD_IMAGE(Pmenuoptions, "images/menu_principal/options.bmp"); + LOAD_IMAGE(Pmenuquitter, "images/menu_principal/quitter.bmp"); + LOAD_IMAGE(Pchoixvoleur, "images/menu_choix_classe/voleur.bmp"); + LOAD_IMAGE(Pchoixpretre, "images/menu_choix_classe/pretre.bmp"); + LOAD_IMAGE(Pchoixpaladin, "images/menu_choix_classe/paladin.bmp"); + LOAD_IMAGE(Pcurseurennemis, "images/jeu/curseur.bmp"); + LOAD_IMAGE(Pcurseurallies, "images/jeu/curseurpersos.bmp"); + LOAD_IMAGE(Pcadrecible, "images/jeu/cadre_cible.bmp"); + LOAD_IMAGE(Pactive, "images/jeu/active.bmp"); + LOAD_IMAGE(Pdesactive, "images/jeu/desactive.bmp"); + LOAD_IMAGE(Pcadreactions, "images/jeu/cadre_actions.bmp"); + LOAD_IMAGE(Pactionselectionnee, "images/jeu/cadre_actions_select.bmp"); + LOAD_IMAGE(Pactiondesactivee, "images/jeu/cadre_actions_unactive.bmp"); + LOAD_IMAGE(Pmort, "images/jeu/mort.bmp"); for (i = 0;i < 5;i++) surfaces->Tennemi[i] = surfaces->Pgobelin; +#undef LOAD_IMAGE + //définition de la transparence alpha dans les surfaces SDL_SetColorKey(surfaces->Pgobelin,SDL_SRCCOLORKEY,SDL_MapRGB(surfaces->Pecran->format,0,255,18)); SDL_SetColorKey(surfaces->Ppretre,SDL_SRCCOLORKEY,SDL_MapRGB(surfaces->Pecran->format,39,189,31)); @@ -191,6 +205,8 @@ void Fchargerimages (SURFACES *surfaces) SDL_SetColorKey(surfaces->Pactive,SDL_SRCCOLORKEY,SDL_MapRGB(surfaces->Pecran->format,255,255,255)); SDL_SetColorKey(surfaces->Pdesactive,SDL_SRCCOLORKEY,SDL_MapRGB(surfaces->Pecran->format,255,255,255)); SDL_SetColorKey(surfaces->Pmort,SDL_SRCCOLORKEY,SDL_MapRGB(surfaces->Pecran->format,255,255,255)); + + return 0; } void Fdechargerimages (SURFACES *surfaces)//dechargement des surfaces alouées diff --git a/prototypes.h b/prototypes.h index 3957017..2634be1 100644 --- a/prototypes.h +++ b/prototypes.h @@ -12,7 +12,7 @@ int Fjouer (SURFACES *surfaces, POSITIONS *positions, PERSONNAGES persos[],ENNEM void Fblitterpersos (SURFACES *surfaces, POSITIONS *positions, PERSONNAGES persos[]); void Finitialiserpositionspersos (SURFACES *surfaces,POSITIONS *positions); void Finitialisersurfaces (SURFACES *surfaces); -void Fchargerimages (SURFACES *surfaces); +int Fchargerimages (SURFACES *surfaces); void Fdechargerimages (SURFACES *surfaces); void inverse(int *bool); void Finitialiserpositions (POSITIONS *positions, SURFACES *surfaces); |