#include "ball.h" Ball::Ball() { x = 400; y = 225; radius = 25; speed_x = 3; speed_y = 3; } Ball::~Ball() { } void Ball::Update() { x += speed_x; y += speed_y; CheckCollision(); } void Ball::SetScreenSize(int width, int height) { screenWidth = width; screenHeight = height; } void Ball::CheckCollision() { if ((x - radius <= 0) or (x + radius >= screenWidth)) { speed_x *= -1;} if ((y - radius <= 0) or (y + radius >= screenHeight)) {speed_y *= -1;} }