123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- #include "Ball.h"
- #include "Paddle.h"
- #include "Game.h"
-
-
- Ball::Ball() {
- setRadius(radius - 3);
- setOutlineThickness(3);
- setOutlineColor(sf::Color::Black);
- setFillColor(sf::Color::White);
- setOrigin(radius / 2, radius / 2);
- }
-
- Ball::Ball(int r) {
- setRadius(r - 3);
- setOutlineThickness(3);
- setOutlineColor(sf::Color::Black);
- setFillColor(sf::Color::White);
- setOrigin(r / 2, r / 2);
- radius = r;
- }
-
- float Ball::getX() const {
- return getPosition().x;
- }
-
- float Ball::getY() const {
- return getPosition().y;
- }
-
- void Ball::setPosition(float x, float y) {
- sf::Transformable::setPosition(x, y);
- }
-
- float Ball::getSpeed() const {
- return ballSpeed;
- }
-
- void Ball::move(float x, float y) {
- sf::Transformable::move(x, y);
- }
-
- float Ball::getRadius() const {
- return radius;
- }
-
-
- Paddle::Paddle() {
- size.x = 25;
- size.y = 100;
- setSize(sf::Vector2f(25, 100) - sf::Vector2f(3, 3));
- setOutlineThickness(3);
- setOutlineColor(sf::Color::Black);
- setFillColor(sf::Color(200, 200, 200));
- setOrigin(sf::Vector2f(25, 100) / 2.f);
- }
-
- float Paddle::getY() const {
- return getPosition().y;
- }
-
- float Paddle::getX() const {
- return getPosition().x;
- }
-
- void Paddle::setPosition(float x, float y) {
- sf::Transformable::setPosition(x, y);
- }
-
- sf::Vector2f Paddle::getSize() const {
- return size;
- }
-
- void Paddle::move(float x, float y) {
- sf::Transformable::move(x, y);
- }
-
- Game::Game() {
- isPlaying = false;
- AITime = sf::seconds(0.1);
- paddleSpeed = 400;
- rightPaddleSpeed = 0;
- ballAngle = 0;
- }
|