aboutsummaryrefslogtreecommitdiff
path: root/src/pong.c
diff options
context:
space:
mode:
authorAtsutane <atsutane@freethoughts.de>2009-05-07 11:29:23 +0200
committerAtsutane <atsutane@freethoughts.de>2009-05-07 11:29:23 +0200
commitab67ea14b229a1fb2402cdc546cf2450635a458d (patch)
tree7b8732288f7c7fb5e970875171a7ccb734b5fd0e /src/pong.c
parent236cbdad591ec56e6d4e2954fb8cdd3e4ff813ae (diff)
downloadpong-ab67ea14b229a1fb2402cdc546cf2450635a458d.tar.gz
pong-ab67ea14b229a1fb2402cdc546cf2450635a458d.tar.bz2
Cleaned a bit up.
Diffstat (limited to 'src/pong.c')
-rw-r--r--src/pong.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/src/pong.c b/src/pong.c
index 6f1928a..c8c9924 100644
--- a/src/pong.c
+++ b/src/pong.c
@@ -296,6 +296,7 @@ void ball_launch(struct game_data *gd) {
mvaddch(p->y, 0, ' ');
mvaddch(p->y+1, 0, ' ');
mvaddch(p->y+2, 0, ' ');
+
p->y = gd->ball->y;
/* Check if it's the turn of the player,
@@ -394,6 +395,8 @@ int game(void) {
p=0;
gd->ball->mv_right = TRUE;
+ timeout(0); /* set delay non blocking */
+
mvaddch(gd->p1->y-2, 0, '|');
mvaddch(gd->p1->y-1, 0, '|');
mvaddch(gd->p1->y, 0, '|');
@@ -493,20 +496,14 @@ int main(void) {
nonl(); /* Receive \r instead of \n */
curs_set(0); /* Set Cursor invisible */
cbreak(); /* No line buffering */
- 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);
mvprintw(y/2, x/3, "Player %d wins.", winner);
- timeout(-1);
+ timeout(-1); /* Set delay to blocking */
getch();
return EXIT_SUCCESS;