From 0a58c87f21ec0717e17318528a7c252c9d0997e7 Mon Sep 17 00:00:00 2001 From: Olivier Gayot Date: Sun, 4 Sep 2016 17:36:59 +0200 Subject: started removing SURFACES and POSITIONS Signed-off-by: Olivier Gayot --- battle.c | 30 +++++++++++++++--------------- blits.c | 24 ++++++++++++------------ blits.h | 4 ++-- map.c | 8 +++++--- 4 files changed, 34 insertions(+), 32 deletions(-) diff --git a/battle.c b/battle.c index e18ebb1..874d27a 100644 --- a/battle.c +++ b/battle.c @@ -1,4 +1,5 @@ -#include +#include "rpg.h" + #include "structures.h" #include "constantes.h" @@ -461,27 +462,26 @@ static bool is_battle_over(const struct team_t *t1, const struct team_t *t2) return get_first_alive_character(t2) == NULL; } -int battle(SURFACES *surfaces, POSITIONS *positions, - struct team_t *t1, struct team_t *t2) +int battle(struct team_t *t1, struct team_t *t2) { struct team_t *playing_team; - SDL_BlitSurface(surfaces->background, NULL, surfaces->screen, NULL); + SDL_BlitSurface(rpg_g.surfaces.background, NULL, rpg_g.screen, NULL); /* compute whether the allies or the enemies should begin */ playing_team = (rand() % 2) ? t1 : t2; highlight_current_character(playing_team); - blit_team(surfaces, t1); - blit_team(surfaces, t2); + blit_team(t1); + blit_team(t2); - SDL_Flip(surfaces->screen); + SDL_Flip(rpg_g.screen); while (!is_battle_over(t1, t2)) { struct action_params_t params = { - .surfaces = surfaces, - .positions = positions, + .surfaces = &rpg_g.surfaces, + .positions = &rpg_g.positions, .t1 = t1, .t2 = t2, @@ -494,20 +494,20 @@ int battle(SURFACES *surfaces, POSITIONS *positions, return -1; case ACTION_PERFORMED: - SDL_Flip(surfaces->screen); + SDL_Flip(rpg_g.screen); SDL_Delay(1000); - SDL_BlitSurface(surfaces->background, &positions->degats, - surfaces->screen, &positions->degats); + SDL_BlitSurface(rpg_g.surfaces.background, &rpg_g.positions.degats, + rpg_g.screen, &rpg_g.positions.degats); - SDL_Flip(surfaces->screen); + SDL_Flip(rpg_g.screen); hook_post_action(¶ms); update_current_character(t1, t2, &playing_team); - blit_team(surfaces, t1); - blit_team(surfaces, t2); + blit_team(t1); + blit_team(t2); break; default: break; diff --git a/blits.c b/blits.c index 51ce1e7..4cff601 100644 --- a/blits.c +++ b/blits.c @@ -11,7 +11,7 @@ #include "rpg.h" -static void blit_chr_infos(SURFACES *surfaces, struct chr_t *chr) +static void blit_chr_infos(struct chr_t *chr) { SDL_Color fg={132,215,107,0},bg={100,0,0,0}; char string[256]; @@ -29,8 +29,8 @@ static void blit_chr_infos(SURFACES *surfaces, struct chr_t *chr) chr->pos_hp.y = chr->pos.y + chr->def_surf->h - surf_hp->h - surf_mp->h; chr->pos_mp.y = chr->pos_hp.y + surf_mp->h; - SDL_BlitSurface(surf_hp, NULL, surfaces->Pecran, &chr->pos_hp); - SDL_BlitSurface(surf_mp, NULL, surfaces->Pecran, &chr->pos_mp); + SDL_BlitSurface(surf_hp, NULL, rpg_g.screen, &chr->pos_hp); + SDL_BlitSurface(surf_mp, NULL, rpg_g.screen, &chr->pos_mp); chr->pos_hp.w = surf_hp->w; chr->pos_hp.h = surf_hp->h; @@ -41,25 +41,25 @@ static void blit_chr_infos(SURFACES *surfaces, struct chr_t *chr) SDL_FreeSurface(surf_mp); } -void blit_character(SURFACES *surfaces, struct chr_t *chr) +void blit_character(struct chr_t *chr) { - SDL_BlitSurface(chr->surf, NULL, surfaces->Pecran, &chr->pos); + SDL_BlitSurface(chr->surf, NULL, rpg_g.screen, &chr->pos); if (!chr->alive) { SDL_Rect pos_dead; - pos_dead.x = chr->pos.x + chr->surf->w / 2 - surfaces->Pmort->w / 2; - pos_dead.y = chr->pos.y + chr->surf->h / 2 - surfaces->Pmort->h / 2; + pos_dead.x = chr->pos.x + chr->surf->w / 2 - rpg_g.surfaces.Pmort->w / 2; + pos_dead.y = chr->pos.y + chr->surf->h / 2 - rpg_g.surfaces.Pmort->h / 2; - SDL_BlitSurface(surfaces->Pmort, NULL, surfaces->Pecran, &pos_dead); + SDL_BlitSurface(rpg_g.surfaces.Pmort, NULL, rpg_g.screen, &pos_dead); } - blit_chr_infos(surfaces, chr); + blit_chr_infos(chr); } -void blit_team(SURFACES *surfaces, struct team_t *team) +void blit_team(struct team_t *team) { for (int i = 0; i < team->chr_cnt; i++) { - blit_character(surfaces, &team->chrs[i]); + blit_character(&team->chrs[i]); } } @@ -262,7 +262,7 @@ void display_incr(SURFACES *surfaces, POSITIONS *positions, surf = TTF_RenderText_Blended(rpg_g.font, string, color); - blit_character(surfaces, target); + blit_character(target); SDL_BlitSurface(surf, NULL, surfaces->Pecran, &target->pos_curs); positions->degats.x = target->pos_curs.x; diff --git a/blits.h b/blits.h index 82d03fe..6ac7dbd 100644 --- a/blits.h +++ b/blits.h @@ -8,9 +8,9 @@ void display_incr(SURFACES *, POSITIONS *, struct chr_t *target, unsigned int incr, SDL_Color color); -void blit_team(SURFACES *, struct team_t *team); +void blit_team(struct team_t *team); +void blit_character(struct chr_t *chr); -void blit_character(SURFACES *, struct chr_t *chr); void update_selected_target(SURFACES *, POSITIONS *, struct target_t *target); void update_list_entries(SURFACES *, POSITIONS *, const struct entry_t *entries, int cnt, int selected); diff --git a/map.c b/map.c index 2af443a..6783873 100644 --- a/map.c +++ b/map.c @@ -6,8 +6,7 @@ #include "structures.h" #include "prototypes.h" -int battle(SURFACES *surfaces, POSITIONS *positions, - struct team_t *t1, struct team_t *t2); +int battle(struct team_t *t1, struct team_t *t2); void Fmap (SURFACES*surfaces, POSITIONS* positions, struct team_t *t1, struct team_t *t2) @@ -44,7 +43,10 @@ void Fmap (SURFACES*surfaces, POSITIONS* positions, //une fois le jeu quitté ! Fdechargersurfaces_map(surfaces); #else - battle(surfaces, positions, t1, t2); + (void) surfaces; + (void) positions; + + battle(t1, t2); #endif } -- cgit v1.2.3