From d75f0dfb7a040ff88c39e01fa639ff74300f11a2 Mon Sep 17 00:00:00 2001 From: Olivier Gayot Date: Thu, 8 Jan 2015 18:52:14 +0100 Subject: blit the background only once (no need for a weird function) Signed-off-by: Olivier Gayot --- blits.c | 10 ---------- jouer.c | 7 +------ main.c | 3 +++ prototypes.h | 1 - 4 files changed, 4 insertions(+), 17 deletions(-) diff --git a/blits.c b/blits.c index 0bb6b61..113fd53 100644 --- a/blits.c +++ b/blits.c @@ -289,13 +289,3 @@ void Fblitterpmcible (SURFACES *surfaces,POSITIONS *positions, const struct char SDL_BlitSurface (surfaces->Ppmcible,NULL,surfaces->Pecran,&positions->Vpositionpmcible); TTF_CloseFont (police); } - -void Fblitterfond(SURFACES* surfaces) -{ - SDL_Rect position; - position.x=0; - position.y=0; - surfaces->Pfondjeu=IMG_Load("images/jeu/textures/background.jpg"); - SDL_BlitSurface(surfaces->Pfondjeu,NULL,surfaces->Pecran,&position); - SDL_Flip(surfaces->Pecran); -} diff --git a/jouer.c b/jouer.c index 9081357..9cad17c 100644 --- a/jouer.c +++ b/jouer.c @@ -246,12 +246,7 @@ int Fjouer (SURFACES *surfaces, POSITIONS *positions, struct team_t *t1, struct unsigned int gagne,perdu; - if(surfaces->Pfondjeu!=NULL) - { - SDL_FreeSurface(surfaces->Pfondjeu); - surfaces->Pfondjeu=NULL; - } - Fblitterfond(surfaces); // on blit le fond du jeu + SDL_BlitSurface(surfaces->background, NULL, surfaces->Pecran, NULL); /* compute whether the allies or the enemies should begin */ playing_team = (rand() % 2) ? t1 : t2; diff --git a/main.c b/main.c index 64ad4d2..9fb8150 100644 --- a/main.c +++ b/main.c @@ -243,6 +243,9 @@ int Fchargerimages (SURFACES *surfaces) for (i = 0;i < 5;i++) surfaces->Tennemi[i] = surfaces->Pgobelin; + LOAD_IMAGE(background, "images/jeu/textures/background.jpg"); + surfaces->Pfondjeu = surfaces->background; + #undef LOAD_IMAGE //définition de la transparence alpha dans les surfaces diff --git a/prototypes.h b/prototypes.h index 582bfee..089b5f4 100644 --- a/prototypes.h +++ b/prototypes.h @@ -37,7 +37,6 @@ void blit_character_affinities(SURFACES *, POSITIONS *, const struct character_t void update_list_entries(SURFACES *surfaces, POSITIONS *positions, const struct entry_t *entries, int cnt, int selected); void Fblitterpvcible (SURFACES *surfaces,POSITIONS *positions, const struct character_t *); void Fblitterpmcible (SURFACES *surfaces,POSITIONS *positions, const struct character_t *); -void Fblitterfond(SURFACES* surfaces); Uint32 obtenirPixel(SDL_Surface *surface, int x, int y); void definirPixel(SDL_Surface *surface, int x, int y, Uint32 pixel); -- cgit v1.2.3