|
|
@ -1,4 +1,5 @@ |
|
|
|
#include <stdio.h> |
|
|
|
#include <termios.h> |
|
|
|
|
|
|
|
#define WIDTH 40 //Breite Spielfeld |
|
|
|
#define HEIGHT 20 //Höhe Spielfeld |
|
|
@ -24,6 +25,36 @@ void drawField(int paddle1PositionY, int paddle2PositionY) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
int kbhit(void){ |
|
|
|
struct termios oldt, newt; |
|
|
|
int ch, oldf; |
|
|
|
|
|
|
|
tcgetattr(STDIN_FILENO, &oldt); |
|
|
|
newt = oldt; |
|
|
|
newt.c_lflag &= ~(ICANON | ECHO); |
|
|
|
tcsetattr(STDIN_FILENO, TCSANOW, &newt); |
|
|
|
oldf = fcntl(STDIN_FILENO, F_GETFL, 0); |
|
|
|
fcntl(STDIN_FILENO, F_SETFL, oldf | O_NONBLOCK); |
|
|
|
|
|
|
|
ch = getchar(); |
|
|
|
|
|
|
|
tcsetattr(STDIN_FILENO, TCSANOW, &oldt); |
|
|
|
fcntl(STDIN_FILENO, F_SETFL, oldf); |
|
|
|
|
|
|
|
if (ch != EOF) { |
|
|
|
ungetc(ch, stdin); |
|
|
|
return 1; |
|
|
|
} |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
int getch(void) { |
|
|
|
int ch; |
|
|
|
|
|
|
|
while ((ch = getchar()) == '\n'); |
|
|
|
|
|
|
|
return ch; |
|
|
|
} |
|
|
|
|
|
|
|
int main(){ |
|
|
|
int paddle1PositionY = HEIGHT / 2 - PADDLE_LENGTH / 2; |
|
|
|