diff options
| author | Atsutane <atsutane@freethoughts.de> | 2009-05-05 19:30:38 +0200 |
|---|---|---|
| committer | Atsutane <atsutane@freethoughts.de> | 2009-05-05 19:30:38 +0200 |
| commit | b34388d74a2311aad19aa4ad6562acca2c96d1ba (patch) | |
| tree | 4e028e220d0c585e0494078b5230b5774c9f3ab7 /src/pong.c | |
| parent | 8b856cae1fe70fb9663bbc80d9720d184792828e (diff) | |
| download | pong-b34388d74a2311aad19aa4ad6562acca2c96d1ba.tar.gz pong-b34388d74a2311aad19aa4ad6562acca2c96d1ba.tar.bz2 | |
Fixed some small issues.
Diffstat (limited to 'src/pong.c')
| -rw-r--r-- | src/pong.c | 19 |
1 files changed, 17 insertions, 2 deletions
@@ -361,7 +361,13 @@ int game(void) { int p, r; struct game_data *gd; /* contains all our data */ - gd = init_game_data(); + if ((gd = init_game_data()) == NULL) { + mvprintw(0, 0, "Could not allocate memory for the game_data."); + timeout(-1); + getch(); + return -1; + } + p=0; clocks = clock(); interval = CLOCKS_PER_SEC/4; @@ -372,6 +378,8 @@ int game(void) { ball_movement(gd); p2_ai(gd); + refresh(); + while ((gd->p1->score != 21) && (gd->p2->score != 21)) { if (clocks > clocks + interval) { @@ -399,6 +407,7 @@ int game(void) { draw_statusbar(gd); p++; + clocks = clock(); refresh(); } } @@ -433,9 +442,15 @@ int main(void) { nonl(); /* Receive \r instead of \n */ curs_set(0); /* Set Cursor invisible */ cbreak(); /* No line buffering */ - timeout(250); /* set input timeout to 250 milliseconds */ + timeout(-1); /* set delay blocking */ keypad(stdscr, TRUE); /* Activate keypad */ + mvprintw(0, 0, "Press a key to start."); + refresh(); + getch(); + clear(); + timeout(0); /* set delay non blocking */ + winner = game(); clear(); getmaxyx(stdscr, y, x); |
