|
|
@ -2,14 +2,20 @@ |
|
|
|
|
|
|
|
#define WIDTH 40 //Breite Spielfeld |
|
|
|
#define HEIGHT 20 //Höhe Spielfeld |
|
|
|
#define PADDLE_LENGTH 4 |
|
|
|
#define PADDLE '#' |
|
|
|
|
|
|
|
void drawField() { |
|
|
|
void drawField(int paddle1PositionY, int paddle2PositionY) { |
|
|
|
for (int i = 0; i <= HEIGHT; i++){ |
|
|
|
for (int j = 0; j <= WIDTH; j++){ |
|
|
|
if (i == 0 || i == HEIGHT){ |
|
|
|
printf("-"); |
|
|
|
} else if ("i == 0 || j == WIDTH") { |
|
|
|
} else if ("j == 0 || j == WIDTH") && (i < paddle1PositionY || i >= paddle1PositionY + PADDLE_LENGTH) && (i < paddle2PositionY || i >= paddle2PositionY + PADDLE_LENGTH)) { |
|
|
|
printf("|"); |
|
|
|
} else if (i >= paddle1PositionY && i < paddle1PositionY + PADDLE_LENGTH && j == WIDTH) { |
|
|
|
printf("%c", PADDLE); |
|
|
|
}else if (i >= paddle2PositionY && i < paddle2PositionY + PADDLE_LENGTH && j == 0) { |
|
|
|
printf("%c", PADDLE); |
|
|
|
} else { |
|
|
|
printf(" "); |
|
|
|
} |
|
|
@ -19,7 +25,27 @@ void drawField() { |
|
|
|
} |
|
|
|
|
|
|
|
int main(){ |
|
|
|
drawField(); |
|
|
|
int paddle1PositionY = HEIGHT / 2 - PADDLE_LENGTH / 2; |
|
|
|
int paddle2PositionY = HEIGHT / 2 - PADDLE_LENGTH / 2; |
|
|
|
|
|
|
|
while (1) { |
|
|
|
if (kbhit()){ |
|
|
|
char input = getch(); |
|
|
|
if (input == 'w' && paddle1PositionY > 1) |
|
|
|
{ |
|
|
|
paddle1PositionY--; |
|
|
|
} else if (input == 's' && paddle1PositionY < HEIGHT - PADDLE_LENGTH - 1) { |
|
|
|
paddle1PositionY++; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// Hier Steuerung für Schläger 2 noch reinschreiben |
|
|
|
|
|
|
|
draw Field(paddle1PositionY, paddle2PositionY); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
|