]> git.armaanb.net Git - pong.git/blobdiff - pong.c
Don't allow paddles to go off of screen
[pong.git] / pong.c
diff --git a/pong.c b/pong.c
index 4bda2a7f21bbeae2bfcc795b6409a2986044b149..cea4d2ad555187b3155b73e8ea910a5d80441cf3 100644 (file)
--- a/pong.c
+++ b/pong.c
@@ -78,13 +78,13 @@ main(void) {
                if (key == 'q') {
                        die(0);
                } else if (key == 'k') {
-                       boff += 2;
+                       if (boff < max_y - pad_h) boff += 1;
                } else if (key == 'i') {
-                       boff -= 2;
+                       if (boff > 0) boff -= 1;
                } else if (key == 's') {
-                       aoff += 2;
+                       if (aoff < max_y - pad_h) aoff += 1;
                } else if (key == 'w') {
-                       aoff -= 2;
+                       if (aoff > 0) aoff -= 1;
                }
 
                // Clear screen