diff options
| author | Atsutane <atsutane@freethoughts.de> | 2009-05-05 16:31:45 +0200 |
|---|---|---|
| committer | Atsutane <atsutane@freethoughts.de> | 2009-05-05 16:31:45 +0200 |
| commit | b80bceed91c6a61409872f644678e15f5189c5b5 (patch) | |
| tree | 58ed841fb6b2298293bd473364507db0bd91267c /src/pong.c | |
| parent | 24bbf84853c21e74fa8169cd608216d7dac6c5bb (diff) | |
| download | pong-b80bceed91c6a61409872f644678e15f5189c5b5.tar.gz pong-b80bceed91c6a61409872f644678e15f5189c5b5.tar.bz2 | |
Added clear_statusbar() and draw_statusbar().
Diffstat (limited to 'src/pong.c')
| -rw-r--r-- | src/pong.c | 33 |
1 files changed, 32 insertions, 1 deletions
@@ -57,6 +57,30 @@ struct game_data { }; +/* Clears the last line of the terminal */ +inline void clear_statusbar(unsigned int y, + unsigned int x) { + unsigned int i; + + for (i = 0; i <= x; i++) { + mvaddch(y, i, ' '); + } +} + + +/* Draws the statusbar */ +void draw_statusbar(struct game_data *gd) { + clear_statusbar(gd->max_field_y, + gd->max_field_x); + + mvprintw(gd->max_field_y, 0, + "%02d", gd->p1->score); + mvprintw(gd->max_field_y, + gd->max_field_x, + "%02d", gd->p2->score); +} + + /* Called in the main loop to verify the size * of the current game field and if it changed * to update the size. @@ -76,11 +100,18 @@ bool check_field_size(struct game_data *gd) { /* If size changed, update the data and return FALSE so * it's easy to check if the data changed. */ - if ((gd->max_field_y != y) || (gd->max_field_x != x)) { + if ((gd->max_field_y != y) || + (gd->max_field_x != x)) { + + clear_statusbar(gd->max_field_y, + gd->max_field_x); + gd->max_field_x = x; gd->max_field_y = y; + return FALSE; } + return TRUE; } |
