summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorP. J. McDermott <pjm@nac.net>2013-05-21 17:54:23 (EDT)
committer P. J. McDermott <pjm@nac.net>2013-05-21 17:54:23 (EDT)
commit35e906449a03b1bc23de6a6ea0489febbc8e646f (patch)
treee94e9a1d0a043c9e29d7cb92b7039f039d41e9a5
parentd97f66ef26c89c8bd805cdeafffa959c91ec278b (diff)
downloadcursespong-35e906449a03b1bc23de6a6ea0489febbc8e646f.zip
cursespong-35e906449a03b1bc23de6a6ea0489febbc8e646f.tar.gz
cursespong-35e906449a03b1bc23de6a6ea0489febbc8e646f.tar.bz2
Draw balls.
-rw-r--r--src/ball.c7
-rw-r--r--src/ball.h1
-rw-r--r--src/game.c6
3 files changed, 14 insertions, 0 deletions
diff --git a/src/ball.c b/src/ball.c
index 7484950..8337106 100644
--- a/src/ball.c
+++ b/src/ball.c
@@ -1,4 +1,5 @@
#include <stdlib.h>
+#include <curses.h>
#include "ball.h"
@@ -17,3 +18,9 @@ new_ball(int x, int y)
return b;
}
+
+void
+draw_ball(struct ball *b)
+{
+ mvprintw(b->y, b->x, "o");
+}
diff --git a/src/ball.h b/src/ball.h
index c2be172..8297d73 100644
--- a/src/ball.h
+++ b/src/ball.h
@@ -13,5 +13,6 @@ struct ball {
};
struct ball *new_ball(int x, int y);
+void draw_ball(struct ball *b);
#endif
diff --git a/src/game.c b/src/game.c
index a5ae342..56774af 100644
--- a/src/game.c
+++ b/src/game.c
@@ -111,8 +111,14 @@ update(struct game *g)
static void
draw(struct game *g)
{
+ struct ball *b;
+
draw_paddle(&g->players[0]->paddle_h);
draw_paddle(&g->players[0]->paddle_v);
draw_paddle(&g->players[1]->paddle_h);
draw_paddle(&g->players[1]->paddle_v);
+
+ for (b = g->balls_head; b != NULL; b = b->next) {
+ draw_ball(b);
+ }
}