summaryrefslogtreecommitdiff
path: root/battle.c
diff options
context:
space:
mode:
authorOlivier Gayot <og@satcom1.com>2016-09-04 17:59:59 +0200
committerOlivier Gayot <og@satcom1.com>2016-09-04 18:00:35 +0200
commit3b3ed255a05eb0a0a3ed2886c010b952c1b1bd8c (patch)
treef08b104c4d62095835d1ab5a6332356b251bad01 /battle.c
parent0a58c87f21ec0717e17318528a7c252c9d0997e7 (diff)
create a structure battle and make use of itHEADmaster
Signed-off-by: Olivier Gayot <og@satcom1.com>
Diffstat (limited to 'battle.c')
-rw-r--r--battle.c26
1 files changed, 23 insertions, 3 deletions
diff --git a/battle.c b/battle.c
index 874d27a..44764b7 100644
--- a/battle.c
+++ b/battle.c
@@ -1,3 +1,5 @@
+#include "battle.h"
+
#include "rpg.h"
#include "structures.h"
@@ -462,11 +464,29 @@ static bool is_battle_over(const struct team_t *t1, const struct team_t *t2)
return get_first_alive_character(t2) == NULL;
}
-int battle(struct team_t *t1, struct team_t *t2)
+int battle_init(struct battle_t *battle, struct team_t *t1, struct team_t *t2)
{
+ battle->t1 = t1;
+ battle->t2 = t2;
+
+ battle->background = rpg_g.surfaces.background;
+
+ return 0;
+}
+
+void battle_close(struct battle_t *battle)
+{
+ (void) battle;
+}
+
+int battle_run(struct battle_t *battle)
+{
+ struct team_t *t1 = battle->t1;
+ struct team_t *t2 = battle->t2;
+
struct team_t *playing_team;
- SDL_BlitSurface(rpg_g.surfaces.background, NULL, rpg_g.screen, NULL);
+ SDL_BlitSurface(battle->background, NULL, rpg_g.screen, NULL);
/* compute whether the allies or the enemies should begin */
playing_team = (rand() % 2) ? t1 : t2;
@@ -498,7 +518,7 @@ int battle(struct team_t *t1, struct team_t *t2)
SDL_Delay(1000);
- SDL_BlitSurface(rpg_g.surfaces.background, &rpg_g.positions.degats,
+ SDL_BlitSurface(battle->background, &rpg_g.positions.degats,
rpg_g.screen, &rpg_g.positions.degats);
SDL_Flip(rpg_g.screen);