]> git.armaanb.net Git - pong.git/blobdiff - pong.c
Reset y value of ball after point
[pong.git] / pong.c
diff --git a/pong.c b/pong.c
index eba648aa7b483c1036be7175e5af468dd9076e65..a61bc0d68bc5986ced25f223cf274c9e275d97e4 100644 (file)
--- a/pong.c
+++ b/pong.c
@@ -151,18 +151,26 @@ main(void) {
                        speed *= 0.9;
                } else if (x >= max_x - 1 || x <= 1) {
                        // Ball goes out of bounds
-                       if (x <=1) {
+                       if (x <= 1) {
                                b_score += 1;
+                               mvprintw(0, 0, "PLAYER B SCORES");
                        } else {
                                a_score += 1;
+                               mvprintw(0, 0, "PLAYER A SCORES");
                        }
+                       refresh();
+
+                       // Reset to default values
                        x = max_x/2;
+                       y = max_y / 2;
                        slope_x = randslope();
                        index_dir = randsign();
                        speed = randspeed();
                        aoff = max_y / 2 - pad_h;
                        boff = max_y / 2 - pad_h;
+
                        sleep(1);
+                       clear();
                } else if (y == 0 || y == max_y) {
                        // Ball hits top or bottom wall
                        index_dir *= -1;