|
@@ -30,14 +30,14 @@ string resourcesDir()
|
30
|
30
|
/// \return Application exit code
|
31
|
31
|
///
|
32
|
32
|
////////////////////////////////////////////////////////////
|
|
33
|
+
|
33
|
34
|
int main()
|
34
|
35
|
{
|
35
|
36
|
srand(static_cast<unsigned int>(time(NULL)));
|
36
|
37
|
|
37
|
38
|
// Define some constants
|
38
|
39
|
const float pi = 3.1415;
|
39
|
|
- const int gameWidth = 800;
|
40
|
|
- const int gameHeight = 600;
|
|
40
|
+
|
41
|
41
|
|
42
|
42
|
// Create the window of the application
|
43
|
43
|
sf::RenderWindow window(sf::VideoMode(gameWidth, gameHeight, 32), "SFML Pong",
|
|
@@ -197,18 +197,9 @@ int main()
|
197
|
197
|
isPlaying = false;
|
198
|
198
|
pauseMessage.setString("You Won!\n" + inputString);
|
199
|
199
|
}
|
200
|
|
- if (ball.getY() - ball.getRadius() < 0.f)
|
201
|
|
- {
|
202
|
|
- ballSound.play();
|
203
|
|
- ball.setAngle(-ball.getAngle());
|
204
|
|
- ball.setPosition(ball.getX(), ball.getRadius() + 0.1f);
|
205
|
|
- }
|
206
|
|
- if (ball.getY() + ball.getRadius() > gameHeight)
|
207
|
|
- {
|
208
|
|
- ballSound.play();
|
209
|
|
- ball.setAngle(-ball.getAngle());
|
210
|
|
- ball.setPosition(ball.getX(), gameHeight - ball.getRadius() - 0.1f);
|
211
|
|
- }
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+ ball.checkCollisions(ballSound);
|
212
|
203
|
|
213
|
204
|
// Check the collisions between the ball and the paddles
|
214
|
205
|
// Left Paddle
|