diff options
author | P. J. McDermott <pjm@nac.net> | 2013-05-20 15:20:37 (EDT) |
---|---|---|
committer | P. J. McDermott <pjm@nac.net> | 2013-05-20 15:20:37 (EDT) |
commit | 17b37f5bb462c29e2b8c94068c4b54e1af39b2b7 (patch) | |
tree | b5e3669410e4c3cc16c6f8accb4f146f0422fe37 /src | |
parent | 6c69108044469c2ec69ad27eb768ca4680e131e1 (diff) | |
download | cursespong-17b37f5bb462c29e2b8c94068c4b54e1af39b2b7.zip cursespong-17b37f5bb462c29e2b8c94068c4b54e1af39b2b7.tar.gz cursespong-17b37f5bb462c29e2b8c94068c4b54e1af39b2b7.tar.bz2 |
Draw the paddles on the screen.
Diffstat (limited to 'src')
-rw-r--r-- | src/game.c | 52 | ||||
-rw-r--r-- | src/game.h | 1 | ||||
-rw-r--r-- | src/main.c | 3 |
3 files changed, 56 insertions, 0 deletions
@@ -1,8 +1,11 @@ #include <stdlib.h> +#include <curses.h> #include "game.h" #include "player.h" +static void draw_paddles(struct game *g); + struct game * new_game(void) { @@ -27,3 +30,52 @@ free_game(struct game *g) free(g); } + +void +draw_game(struct game *g) +{ + draw_paddles(g); +} + +static void +draw_paddles(struct game *g) +{ + int off; + int pos; + + /* Player 1 horizontal paddle */ + off = g->players[0]->paddle_h.pos; + off -= g->players[0]->paddle_h.size / 2; + for (pos = 0; pos < g->players[0]->paddle_h.size; ++pos) { + attr_on(WA_REVERSE, NULL); + mvprintw(23, off + pos, " "); + attr_off(WA_REVERSE, NULL); + } + + /* Player 1 vertical paddle */ + off = g->players[0]->paddle_v.pos; + off -= g->players[0]->paddle_v.size / 2; + for (pos = 0; pos < g->players[0]->paddle_v.size; ++pos) { + attr_on(WA_REVERSE, NULL); + mvprintw(off + pos, 1, " "); + attr_off(WA_REVERSE, NULL); + } + + /* Player 2 horizontal paddle */ + off = g->players[1]->paddle_h.pos; + off -= g->players[1]->paddle_h.size / 2; + for (pos = 0; pos < g->players[1]->paddle_h.size; ++pos) { + attr_on(WA_REVERSE, NULL); + mvprintw(1, off + pos, " "); + attr_off(WA_REVERSE, NULL); + } + + /* Player 2 vertical paddle */ + off = g->players[1]->paddle_v.pos; + off -= g->players[1]->paddle_v.size / 2; + for (pos = 0; pos < g->players[1]->paddle_v.size; ++pos) { + attr_on(WA_REVERSE, NULL); + mvprintw(off + pos, 78, " "); + attr_off(WA_REVERSE, NULL); + } +} @@ -9,5 +9,6 @@ struct game { struct game *new_game(void); void free_game(struct game *g); +void draw_game(struct game *g); #endif @@ -13,6 +13,9 @@ main(void) init_curses(); g = new_game(); + draw_game(g); + getch(); + free_game(g); fini_curses(); |