|
@@ -53,7 +53,7 @@ void Ball::setAngle(float a) {
|
53
|
53
|
angle = a;
|
54
|
54
|
}
|
55
|
55
|
|
56
|
|
-void Ball::checkLeftPaddle(Paddle leftPaddle, sf::Sound ballSound) {
|
|
56
|
+void Ball::checkLeftPaddle(const Paddle &leftPaddle, sf::Sound &ballSound) {
|
57
|
57
|
|
58
|
58
|
if (getPosition().x - radius < leftPaddle.getX() + leftPaddle.getSize().x / 2 &&
|
59
|
59
|
getPosition().x - radius > leftPaddle.getX() &&
|
|
@@ -71,7 +71,7 @@ void Ball::checkLeftPaddle(Paddle leftPaddle, sf::Sound ballSound) {
|
71
|
71
|
}
|
72
|
72
|
}
|
73
|
73
|
|
74
|
|
-void Ball::checkRightPaddle(Paddle rightPaddle, sf::Sound ballSound) {
|
|
74
|
+void Ball::checkRightPaddle(const Paddle &rightPaddle, sf::Sound &ballSound) {
|
75
|
75
|
|
76
|
76
|
if (getPosition().x + radius > rightPaddle.getX() - rightPaddle.getSize().x / 2 &&
|
77
|
77
|
getPosition().x + radius < rightPaddle.getX() &&
|
|
@@ -79,16 +79,16 @@ void Ball::checkRightPaddle(Paddle rightPaddle, sf::Sound ballSound) {
|
79
|
79
|
getPosition().y - radius <= rightPaddle.getY() + rightPaddle.getSize().y / 2)
|
80
|
80
|
{
|
81
|
81
|
if (getPosition().y > rightPaddle.getY())
|
82
|
|
- angle = radius - angle + (rand() % 20) * radius / 180;
|
|
82
|
+ angle = M_PI - angle + (rand() % 20) * M_PI / 180;
|
83
|
83
|
else
|
84
|
|
- angle = radius - angle - (rand() % 20) * M_PI / 180;
|
|
84
|
+ angle = M_PI - angle - (rand() % 20) * M_PI / 180;
|
85
|
85
|
|
86
|
86
|
ballSound.play();
|
87
|
87
|
setPosition(rightPaddle.getX() - radius - rightPaddle.getSize().x / 2 - 0.1, getPosition().y);
|
88
|
88
|
}
|
89
|
89
|
}
|
90
|
90
|
|
91
|
|
-void Ball::checkCollisions(sf::Sound ballSound) {
|
|
91
|
+void Ball::checkCollisions(sf::Sound &ballSound) {
|
92
|
92
|
if (getY() - radius < 0.f)
|
93
|
93
|
{
|
94
|
94
|
ballSound.play();
|