From b592632f073e6cabae007a35ee9a86f6bb2d1634 Mon Sep 17 00:00:00 2001 From: Atsutane Date: Thu, 7 May 2009 11:37:09 +0200 Subject: ball_movement: Added check if the terminal was resized. --- src/pong.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/pong.c') diff --git a/src/pong.c b/src/pong.c index d7f7467..b2efba6 100644 --- a/src/pong.c +++ b/src/pong.c @@ -184,6 +184,14 @@ void ball_movement(struct game_data *gd) { /* Clear current position of the ball */ mvaddch(gd->ball->y, gd->ball->x, ' '); + /* If the Terminal was resized, place ball to + * the center of the Terminal. + */ + if (check_field_size(gd) == FALSE) { + gd->ball->y = gd->max_field_y / 2; + gd->ball->x = gd->max_field_x / 2; + } + if (gd->ball->x == 1) { /* Does it hit p1s pad? */ if ((gd->ball->y > gd->p1->y-3) && -- cgit v1.2.3-70-g09d2