public static void CheckAndFixCollisionWithBoarders(MovableBall ball, int height, int width) { if (ball.GetXCoordinate() < 0 || ball.GetXCoordinate() > width) { ball.SetXSpeed(ball.GetXSpeed() * -1); } if (ball.GetYCoordinate() < 0 || ball.GetYCoordinate() > height) { ball.SetYSpeed(ball.GetYSpeed() * -1); } }
private void DrawBall(MovableBall ball, Graphics graphics) { RectangleF rect = new RectangleF(ball.GetXCoordinate(), ball.GetYCoordinate(), ball.GetRadius(), ball.GetRadius()); graphics.DrawEllipse(blackPen, rect); ball.Move(); }