diff options
Diffstat (limited to 'menuchoixpersos.c')
-rw-r--r-- | menuchoixpersos.c | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/menuchoixpersos.c b/menuchoixpersos.c index 91e0c7d..0d580c6 100644 --- a/menuchoixpersos.c +++ b/menuchoixpersos.c @@ -8,23 +8,15 @@ #include <SDL/SDL_ttf.h> #include "players.h" -static -struct team_t *new_ally_team(SURFACES *surfaces, - const enum character_class_t *classes, int cnt) +static void init_team_players(struct team_t *team, bool left, + const enum character_class_t *classes, SURFACES *surfaces) { - struct team_t *team = malloc(sizeof(struct team_t)); - - team->name = "Team Player"; - team->cpu = false; - team->chr_cnt = cnt; - team->chrs = malloc(sizeof(struct character_t) * team->chr_cnt); - for (int i = 0; i < team->chr_cnt; i++) { struct character_t *chr = &team->chrs[i]; chr->name = "Player"; - chr->cpu = false; chr->team = team; + chr->cpu = team->cpu; chr->class_ = classes[i]; chr->alive = true; @@ -65,9 +57,24 @@ struct team_t *new_ally_team(SURFACES *surfaces, } /* set its position */ - chr->pos.x = 20; - chr->pos.y = (YWIN / (cnt + 1)) * (i + 1) - chr->def_surf->h / 2; + chr->pos.x = (left) ? 20 : XWIN - chr->surf->w - 20; + chr->pos.y = (YWIN / ((team->chr_cnt + 1) * 2)) * (2 * (i + 1)) - chr->surf->h / 2; } +} + + +static +struct team_t *new_ally_team(SURFACES *surfaces, + const enum character_class_t *classes, int cnt) +{ + struct team_t *team = malloc(sizeof(struct team_t)); + + team->name = "Team Player"; + team->cpu = false; + team->chr_cnt = cnt; + team->chrs = malloc(sizeof(struct character_t) * team->chr_cnt); + + init_team_players(team, true, classes, surfaces); return team; } |