|
@ -55,7 +55,7 @@ void drawField(int paddle1PositionY, int paddle2PositionY, Ball ball, int score1 |
|
|
printf("Drücken Sie 'q', um das Spiel zu beenden.\n"); |
|
|
printf("Drücken Sie 'q', um das Spiel zu beenden.\n"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
int kbhit(void){ |
|
|
|
|
|
|
|
|
int kb_hit(void){ |
|
|
struct termios oldt, newt; |
|
|
struct termios oldt, newt; |
|
|
int ch, oldf; |
|
|
int ch, oldf; |
|
|
|
|
|
|
|
@ -78,7 +78,7 @@ int kbhit(void){ |
|
|
return 0; |
|
|
return 0; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
int getch(void) { |
|
|
|
|
|
|
|
|
int get_ch(void) { |
|
|
int ch; |
|
|
int ch; |
|
|
|
|
|
|
|
|
while ((ch = getchar()) == '\n'); |
|
|
while ((ch = getchar()) == '\n'); |
|
@ -157,8 +157,8 @@ int pong(){ |
|
|
|
|
|
|
|
|
while (score1 < maxScore && score2 < maxScore) { |
|
|
while (score1 < maxScore && score2 < maxScore) { |
|
|
//Steuerung für Schläger 1 |
|
|
//Steuerung für Schläger 1 |
|
|
if (!isPaused && kbhit()){ |
|
|
|
|
|
char input = getch(); |
|
|
|
|
|
|
|
|
if (!isPaused && kb_hit()){ |
|
|
|
|
|
char input = get_ch(); |
|
|
if (input == 'w' && paddle1PositionY > 1) |
|
|
if (input == 'w' && paddle1PositionY > 1) |
|
|
{ |
|
|
{ |
|
|
paddle1PositionY--; |
|
|
paddle1PositionY--; |
|
@ -174,8 +174,8 @@ int pong(){ |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//Steuerung für Schläger 2 |
|
|
//Steuerung für Schläger 2 |
|
|
if (!isPaused && kbhit()){ |
|
|
|
|
|
char input = getch(); |
|
|
|
|
|
|
|
|
if (!isPaused && kb_hit()){ |
|
|
|
|
|
char input = get_ch(); |
|
|
if (input == 'i' && paddle2PositionY > 1){ |
|
|
if (input == 'i' && paddle2PositionY > 1){ |
|
|
paddle2PositionY--; |
|
|
paddle2PositionY--; |
|
|
} else if (input == 'k' && paddle2PositionY < HEIGHT - PADDLE_LENGTH - 1){ |
|
|
} else if (input == 'k' && paddle2PositionY < HEIGHT - PADDLE_LENGTH - 1){ |
|
|