summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArmaan Bhojwani <me@armaanb.net>2021-05-15 20:33:00 -0400
committerArmaan Bhojwani <me@armaanb.net>2021-05-15 20:33:00 -0400
commitdb8443ee2307b9c87fe8983b3ce4299ea2b60d79 (patch)
tree96086f6a8885be451219cf4566f69f4208c4f447
parent511a499c7d34ce28600121cf030387eb4b509530 (diff)
downloadpong-db8443ee2307b9c87fe8983b3ce4299ea2b60d79.tar.gz
Don't allow paddles to go off of screen
-rw-r--r--pong.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/pong.c b/pong.c
index 4bda2a7..cea4d2a 100644
--- 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