# Calculating ball trajectory in Pong

I'm making a Pong game and I'm just looking for a simple way to calculate a straight travelling path for the ball based on the angle of the ball. How would I go about implementing something like this? Here is my code right now:

public void UpdatePosition()
{
//For now let's just implement a very primitive movement algorithm
//TODO: Movement calculation based on angle of the ball
ball.velocity = (ball.angle < Math.PI / 2) ? 5 : -5;
ball.Point = new Point(ball.Point.X + ball.velocity, ball.Point.Y + ball.velocity2);

//Check if the suggested point is beyond the boundaries of the window
if (ball.Point.X > ball.view.Boundaries.Width || ball.Point.Y > ball.view.Boundaries.Height || ball.Point.X < 0
|| ball.Point.Y < 0)
{
ball.Collision(CollisionType.Boundary); // If it does raise collision event
}

//Check if the new point collides with the hitbox of a player paddle
{
}
}

• The angle of the ball relative to what? The surface of the paddle? – Anko Apr 18 '14 at 14:27
• Well yeah, the angle that the ball will move in. – Overly Excessive Apr 18 '14 at 14:39

Velocity is a 2-dimensional value, representing the speed in both the X and Y directions. I notice you have velocity and velocity2; it might make things easier to use a 2D vector for velocity, like you do for position.
ball.velocity = new Point(5 * cos(ball.angle), 5 * sin(ball.angle));

ball.Point = ball.Point + ball.velocity;