|
|
@ -45,6 +45,7 @@ void drawField(int paddle1PositionY, int paddle2PositionY, Ball ball, int score1 |
|
|
|
} |
|
|
|
|
|
|
|
printf("Spieler 1: %d\tSpieler 2: %d\n", score1, score2); |
|
|
|
printf("Drücken Sie 'p', um das Spiel zu pausieren.\n"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
@ -86,28 +87,38 @@ int main(){ |
|
|
|
int score1 = 0; |
|
|
|
int score2 = 0; |
|
|
|
int maxScore = 5; |
|
|
|
int isPaused = 0; |
|
|
|
|
|
|
|
while (1) { |
|
|
|
//Steuerung für Schläger 1 |
|
|
|
if (kbhit()){ |
|
|
|
char input = getch(); |
|
|
|
if (input == 'w' && paddle1PositionY > 1) |
|
|
|
if (input == 'w' && paddle1PositionY > 1 && !isPaused) |
|
|
|
{ |
|
|
|
paddle1PositionY--; |
|
|
|
} else if (input == 's' && paddle1PositionY < HEIGHT - PADDLE_LENGTH - 1) { |
|
|
|
} else if (input == 's' && paddle1PositionY < HEIGHT - PADDLE_LENGTH - 1 && !isPaused) { |
|
|
|
paddle1PositionY++; |
|
|
|
} else if (input == 'p') { |
|
|
|
isPaused = !isPaused; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//Steuerung für Schläger 2 |
|
|
|
if (kbhit()){ |
|
|
|
char input = getch(); |
|
|
|
if (input == 'i' && paddle2PositionY > 1) { |
|
|
|
if (input == 'i' && paddle2PositionY > 1 && !isPaused) { |
|
|
|
paddle2PositionY--; |
|
|
|
} else if (input == 'k' && paddle2PositionY < HEIGHT - PADDLE_LENGTH - 1){ |
|
|
|
} else if (input == 'k' && paddle2PositionY < HEIGHT - PADDLE_LENGTH - 1 && !isPaused){ |
|
|
|
paddle2PositionY++; |
|
|
|
} else if (input == 'p') { |
|
|
|
isPaused = !isPaused; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//Wenn Pauseiert |
|
|
|
if (isPaused) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
//Bewegung Ball |
|
|
|
ball.x += ball.speedX; |
|
|
|