|
@ -107,12 +107,22 @@ int main(){ |
|
|
ball.x += ball.speedX; |
|
|
ball.x += ball.speedX; |
|
|
ball.y += ball.speedY; |
|
|
ball.y += ball.speedY; |
|
|
|
|
|
|
|
|
|
|
|
//Kollision Ball (mit Schlägern und Wänden) |
|
|
|
|
|
if (ball.y <= 0 || ball.y >= HEIGHT - 1){ |
|
|
|
|
|
ball.speedY = -ball.speedY; |
|
|
|
|
|
} |
|
|
|
|
|
if (ball.x == 1 && (ball.y >= paddle2PositionY && ball.y < paddle2PositionY + PADDLE_LENGTH)){ |
|
|
|
|
|
ball.speedX = -ball.speedX; |
|
|
|
|
|
} |
|
|
|
|
|
if (ball.x == WIDTH - 1 && (ball.y >= paddle1PositionY && ball.y < paddle1PositionY + PADDLE_LENGTH)){ |
|
|
|
|
|
ball.speedX = -ball.speedX; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
draw Field(paddle1PositionY, paddle2PositionY); |
|
|
draw Field(paddle1PositionY, paddle2PositionY); |
|
|
|
|
|
|
|
|
usleep(100000); //Verlangsamen Schleife/Spiel |
|
|
usleep(100000); //Verlangsamen Schleife/Spiel |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return 0; |
|
|
return 0; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|