diff --git a/src/main/c/Pong/game.c b/src/main/c/Pong/game.c index e8b68d6..6453f7a 100644 --- a/src/main/c/Pong/game.c +++ b/src/main/c/Pong/game.c @@ -1,12 +1,20 @@ #include #include +#include #define WIDTH 40 //Breite Spielfeld #define HEIGHT 20 //Höhe Spielfeld #define PADDLE_LENGTH 4 #define PADDLE '#' +// Bildschirm löschen nach Veränderung Position +void clearScreen() { + system("clear"); +} + void drawField(int paddle1PositionY, int paddle2PositionY) { + clearScreen(); + for (int i = 0; i <= HEIGHT; i++){ for (int j = 0; j <= WIDTH; j++){ if (i == 0 || i == HEIGHT){ @@ -15,7 +23,7 @@ void drawField(int paddle1PositionY, int paddle2PositionY) { printf("|"); } else if (i >= paddle1PositionY && i < paddle1PositionY + PADDLE_LENGTH && j == WIDTH) { printf("%c", PADDLE); - }else if (i >= paddle2PositionY && i < paddle2PositionY + PADDLE_LENGTH && j == 0) { + } else if (i >= paddle2PositionY && i < paddle2PositionY + PADDLE_LENGTH && j == 0) { printf("%c", PADDLE); } else { printf(" "); @@ -61,6 +69,7 @@ int main(){ int paddle2PositionY = HEIGHT / 2 - PADDLE_LENGTH / 2; while (1) { + //Steuerung für Schläger 1 if (kbhit()){ char input = getch(); if (input == 'w' && paddle1PositionY > 1)