diff options
Diffstat (limited to 'src/game.c')
-rw-r--r-- | src/game.c | 13 |
1 files changed, 12 insertions, 1 deletions
@@ -12,7 +12,7 @@ static void update(struct game *g); static void draw(struct game *g); struct game * -new_game(void) +new_game(char balls) { struct game *g; @@ -23,6 +23,8 @@ new_game(void) g->players[0] = new_player(0); g->players[1] = new_player(1); + g->min_balls = balls; + g->cur_balls = 0; return g; } @@ -91,10 +93,19 @@ input(struct game *g) static void update(struct game *g) { + struct ball *b; + update_paddle(&g->players[0]->paddle_h); update_paddle(&g->players[0]->paddle_v); update_paddle(&g->players[1]->paddle_h); update_paddle(&g->players[1]->paddle_v); + + while (g->cur_balls < g->min_balls) { + b = new_ball(BALL_START_X_NORMAL, BALL_START_Y_NORMAL); + b->next = g->balls_head; + g->balls_head = b; + ++g->cur_balls; + } } static void |