From cbf0e4a79b73f622515a622ae9b7fad74f4f9d32 Mon Sep 17 00:00:00 2001 From: fdai8040 Date: Wed, 31 Jan 2024 16:27:49 +0000 Subject: [PATCH] refactoring:_optimierungpausierung --- src/main/c/Pong/game.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/c/Pong/game.c b/src/main/c/Pong/game.c index 877ea22..4d72e10 100644 --- a/src/main/c/Pong/game.c +++ b/src/main/c/Pong/game.c @@ -91,12 +91,12 @@ int main(){ while (1) { //Steuerung für Schläger 1 - if (kbhit()){ + if (!isPaused && kbhit()){ char input = getch(); - if (input == 'w' && paddle1PositionY > 1 && !isPaused) + if (input == 'w' && paddle1PositionY > 1) { paddle1PositionY--; - } else if (input == 's' && paddle1PositionY < HEIGHT - PADDLE_LENGTH - 1 && !isPaused) { + } else if (input == 's' && paddle1PositionY < HEIGHT - PADDLE_LENGTH - 1) { paddle1PositionY++; } else if (input == 'p') { isPaused = !isPaused; @@ -104,11 +104,11 @@ int main(){ } //Steuerung für Schläger 2 - if (kbhit()){ + if (!isPaused && kbhit()){ char input = getch(); - if (input == 'i' && paddle2PositionY > 1 && !isPaused) { + if (input == 'i' && paddle2PositionY > 1){ paddle2PositionY--; - } else if (input == 'k' && paddle2PositionY < HEIGHT - PADDLE_LENGTH - 1 && !isPaused){ + } else if (input == 'k' && paddle2PositionY < HEIGHT - PADDLE_LENGTH - 1){ paddle2PositionY++; } else if (input == 'p') { isPaused = !isPaused; @@ -117,6 +117,7 @@ int main(){ //Wenn Pauseiert if (isPaused) { + drawField(paddle1PositionY, paddle2PositionY, ball, score1, score2, 1); continue; }