Browse Source

refactoring:_optimierungpausierung

remotes/origin/branchJulia
fdai8040 11 months ago
parent
commit
cbf0e4a79b
  1. 13
      src/main/c/Pong/game.c

13
src/main/c/Pong/game.c

@ -91,12 +91,12 @@ int main(){
while (1) { while (1) {
//Steuerung für Schläger 1 //Steuerung für Schläger 1
if (kbhit()){
if (!isPaused && kbhit()){
char input = getch(); char input = getch();
if (input == 'w' && paddle1PositionY > 1 && !isPaused)
if (input == 'w' && paddle1PositionY > 1)
{ {
paddle1PositionY--; paddle1PositionY--;
} else if (input == 's' && paddle1PositionY < HEIGHT - PADDLE_LENGTH - 1 && !isPaused) {
} else if (input == 's' && paddle1PositionY < HEIGHT - PADDLE_LENGTH - 1) {
paddle1PositionY++; paddle1PositionY++;
} else if (input == 'p') { } else if (input == 'p') {
isPaused = !isPaused; isPaused = !isPaused;
@ -104,11 +104,11 @@ int main(){
} }
//Steuerung für Schläger 2 //Steuerung für Schläger 2
if (kbhit()){
if (!isPaused && kbhit()){
char input = getch(); char input = getch();
if (input == 'i' && paddle2PositionY > 1 && !isPaused) {
if (input == 'i' && paddle2PositionY > 1){
paddle2PositionY--; paddle2PositionY--;
} else if (input == 'k' && paddle2PositionY < HEIGHT - PADDLE_LENGTH - 1 && !isPaused){
} else if (input == 'k' && paddle2PositionY < HEIGHT - PADDLE_LENGTH - 1){
paddle2PositionY++; paddle2PositionY++;
} else if (input == 'p') { } else if (input == 'p') {
isPaused = !isPaused; isPaused = !isPaused;
@ -117,6 +117,7 @@ int main(){
//Wenn Pauseiert //Wenn Pauseiert
if (isPaused) { if (isPaused) {
drawField(paddle1PositionY, paddle2PositionY, ball, score1, score2, 1);
continue; continue;
} }

Loading…
Cancel
Save