From 2e38b367d885f0805a843b99b1b5b62f927dabfc Mon Sep 17 00:00:00 2001 From: fdai8040 Date: Wed, 31 Jan 2024 13:53:00 +0000 Subject: [PATCH] =?UTF-8?q?Hinzuf=C3=BCgen=20Schl=C3=A4gel=202?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/Pong/game.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/c/Pong/game.c b/src/main/c/Pong/game.c index f97a3f0..69d6a31 100644 --- a/src/main/c/Pong/game.c +++ b/src/main/c/Pong/game.c @@ -24,6 +24,7 @@ void drawField(int paddle1PositionY, int paddle2PositionY) { } } + int main(){ int paddle1PositionY = HEIGHT / 2 - PADDLE_LENGTH / 2; int paddle2PositionY = HEIGHT / 2 - PADDLE_LENGTH / 2; @@ -39,7 +40,15 @@ int main(){ } } -// Hier Steuerung für Schläger 2 noch reinschreiben +//Steuerung für Schläger 2 + if (kbhit()){ + char input = getch(); + if (input == 'i' && paddle2PositionY > 1) { + paddle2PositionY--; + } else if (input == 'k' && paddle2PositionY < HEIGHT - PADDLE_LENGTH - 1){ + paddle2PositionY++; + } + } draw Field(paddle1PositionY, paddle2PositionY);