summaryrefslogtreecommitdiff
path: root/battle.c
diff options
context:
space:
mode:
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);