diff options
author | P. J. McDermott <pjm@nac.net> | 2013-05-21 17:50:37 (EDT) |
---|---|---|
committer | P. J. McDermott <pjm@nac.net> | 2013-05-21 17:50:37 (EDT) |
commit | d97f66ef26c89c8bd805cdeafffa959c91ec278b (patch) | |
tree | 96bf1eabfaece5ad310210dd40ea7f08543a15e0 /src/game.c | |
parent | a9c64a158c369bc370c14dd87567fc030fa050e0 (diff) | |
download | cursespong-d97f66ef26c89c8bd805cdeafffa959c91ec278b.zip cursespong-d97f66ef26c89c8bd805cdeafffa959c91ec278b.tar.gz cursespong-d97f66ef26c89c8bd805cdeafffa959c91ec278b.tar.bz2 |
Add (stationary and invisible) balls to the board.
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 |