# Breakout paddle ball bouncing woes

This topic is 3611 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi guys. Im making a brekout game, but i am having problems making the ball bounce farther away when it touches the ends of one of the paddles. This is my code:
if(paddleCollision(&m_paddlePos))
{
//now reflect ball

{
//Hit the right end of the paddle
m_ballVel.y += 5.0f;
if(m_ballVel.x > 0.0f)
m_ballVel.x += 2.5f;
else
m_ballVel.x -= 2.5f;
D3DXVec3Normalize(&m_ballVel, &m_ballVel);
m_ballVel.x *= m_ballSpeed;
m_ballVel.y *= m_ballSpeed;
}
{
//Hit the right end of the paddle
m_ballVel.y += 5.0f;
if(m_ballVel.x > 0.0f)
m_ballVel.x += 2.5f;
else
m_ballVel.x -= 2.5f;
D3DXVec3Normalize(&m_ballVel, &m_ballVel);
m_ballVel.x *= m_ballSpeed;
m_ballVel.y *= m_ballSpeed;
}
}


Basically, what I am trying to do is prevention for when the ball goes up and down, without a real change in velocity. So what I want to do is to make the ball bounce at a greater angle when it collides with the paddle. Anyone got any ideas how i could fix my code?

1. 1
Rutin
32
2. 2
3. 3
4. 4
5. 5

• 11
• 13
• 87
• 11
• 10
• ### Forum Statistics

• Total Topics
632973
• Total Posts
3009615
• ### Who's Online (See full list)

There are no registered users currently online

×