summaryrefslogtreecommitdiffstats
path: root/src/game.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/game.c')
-rw-r--r--src/game.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/game.c b/src/game.c
index 9f7cebd..a5ae342 100644
--- a/src/game.c
+++ b/src/game.c
@@ -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