summaryrefslogtreecommitdiffstats
path: root/src/game.c
diff options
context:
space:
mode:
authorP. J. McDermott <pjm@nac.net>2013-05-21 18:28:17 (EDT)
committer P. J. McDermott <pjm@nac.net>2013-05-21 18:28:17 (EDT)
commitf40768e82a9f396526c30c0bda10388f4746fbea (patch)
tree196ff36cd9abcf12926b63c6817eb90a6a1569e5 /src/game.c
parent4e6e4ab53d3d43725f117c0dbf613b2bd9c7794c (diff)
downloadcursespong-f40768e82a9f396526c30c0bda10388f4746fbea.zip
cursespong-f40768e82a9f396526c30c0bda10388f4746fbea.tar.gz
cursespong-f40768e82a9f396526c30c0bda10388f4746fbea.tar.bz2
Add board clearing functions.
Diffstat (limited to 'src/game.c')
-rw-r--r--src/game.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/game.c b/src/game.c
index c12d731..b496708 100644
--- a/src/game.c
+++ b/src/game.c
@@ -8,6 +8,7 @@
static void wait(struct game *g);
static void input(struct game *g);
+static void clear_game(struct game *g);
static void update(struct game *g);
static void draw(struct game *g);
@@ -45,6 +46,7 @@ run_game(struct game *g)
while (g->running) {
input(g);
+ clear_game(g);
update(g);
draw(g);
wait(g);
@@ -91,6 +93,21 @@ input(struct game *g)
}
static void
+clear_game(struct game *g)
+{
+ struct ball *b;
+
+ clear_paddle(&g->players[0]->paddle_h);
+ clear_paddle(&g->players[0]->paddle_v);
+ clear_paddle(&g->players[1]->paddle_h);
+ clear_paddle(&g->players[1]->paddle_v);
+
+ for (b = g->balls_head; b != NULL; b = b->next) {
+ clear_ball(b);
+ }
+}
+
+static void
update(struct game *g)
{
struct ball *b;