summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArmaan Bhojwani <me@armaanb.net>2021-05-15 21:38:02 -0400
committerArmaan Bhojwani <me@armaanb.net>2021-05-15 21:38:02 -0400
commitbf728d1eb98174938d4f5e895eb563431c9c9cd4 (patch)
treee5adcb90b02569f8e43112d23161ecd03e360868
parentc117414b4574890e3874c09ee8974dce691cd4b1 (diff)
downloadpong-bf728d1eb98174938d4f5e895eb563431c9c9cd4.tar.gz
Add scoring message
-rw-r--r--pong.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/pong.c b/pong.c
index eba648a..72b5602 100644
--- a/pong.c
+++ b/pong.c
@@ -151,11 +151,14 @@ 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();
x = max_x/2;
slope_x = randslope();
index_dir = randsign();
@@ -163,6 +166,7 @@ main(void) {
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;