From 8720b8fba938cf70335143b4ca95ba61edf341e8 Mon Sep 17 00:00:00 2001 From: fdai8040 Date: Wed, 31 Jan 2024 16:47:31 +0000 Subject: [PATCH] =?UTF-8?q?refactoring:=5Fbesser=5Fpunkte=5Fz=C3=A4hlen?= 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, 11 insertions(+) diff --git a/src/main/c/Pong/game.c b/src/main/c/Pong/game.c index b2ca2e0..c1d554f 100644 --- a/src/main/c/Pong/game.c +++ b/src/main/c/Pong/game.c @@ -103,6 +103,17 @@ int checkCollision(Ball ball, int paddle1PositionY, int paddle2PositionY) { ball.speedX = -ball.speedX; } + //Punkte zählen + if (ball.x <= 0){ + return 1; // Spieler 2 gewinnt Punkt + } + + if (ball.x >= WIDTH - 1){ + return 2; // Spieler 1 gewinnt Punkt + } + + return 0; // kein Punkt +} int main(){ int paddle1PositionY = HEIGHT / 2 - PADDLE_LENGTH / 2;