aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAtsutane <atsutane@freethoughts.de>2009-05-07 11:37:09 +0200
committerAtsutane <atsutane@freethoughts.de>2009-05-07 11:37:09 +0200
commitb592632f073e6cabae007a35ee9a86f6bb2d1634 (patch)
treef82d63e9d0dff854b0ce7414dc2b821e3a6048bf /src
parent6f153b1a83b967730b275e90b7eb3509781e92c3 (diff)
downloadpong-b592632f073e6cabae007a35ee9a86f6bb2d1634.tar.gz
pong-b592632f073e6cabae007a35ee9a86f6bb2d1634.tar.bz2
ball_movement: Added check if the terminal was resized.
Diffstat (limited to 'src')
-rw-r--r--src/pong.c8
1 files changed, 8 insertions, 0 deletions
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) &&