1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- #include <SFML/Graphics.hpp>
- #include <SFML/Audio.hpp>
-
- const int gameWidth = 800;
- const int gameHeight = 600;
-
-
- class Paddle : public sf::RectangleShape {
- private:
- float x,
- y;
- sf::Vector2f size;
-
- public:
- Paddle();
- void move(float x, float y);
- void draw(sf::RenderWindow);
- float getX() const;
- float getY() const;
- sf::Vector2f getSize() const;
- void setPosition(float x, float y);
- void render(sf::RenderWindow) const;
-
- };
-
- class Ball : public sf::CircleShape {
- private:
- float radius = 10,
- angle = 0;
- const float ballSpeed = 400;
-
- public:
- Ball();
- Ball(int radius);
- void move(float x, float y);
- void setPosition(float x, float y);
- float getX() const;
- float getY() const;
- float getSpeed() const;
- float getRadius() const;
- float getAngle() const;
- void setAngle(float a);
- void checkLeftPaddle(const Paddle &leftPaddle, sf::Sound &ballSound);
- void checkRightPaddle(const Paddle &rightPaddle, sf::Sound &ballSound);
- void checkCollisions(sf::Sound &ballsound);
-
- };
|