Ball stuck in movement

So I am making a game of pong. I just want to make my ball bounce around the screen. I can get it moving fine if I put this code in

1
2
3
4
if(iPongBallX + iPongBallWidth > iScreenWidth|| iPongBallX < iScreenWidth)
	{
		iBallVelocityX *= -1;
	}


The moment I add something else the balls movement doesn't work. If I add another statement like this the ball will be stuck in place. Can anybody help me as to why?
1
2
3
4
if(iPongBallY + iPongBallHeight > iScreenHeight || iPongBallY < iScreenHeight)
       {
	iBallVelocityY *= -1;
       }


Should I have these IF's in a switch statemtent?
should be iPongBallX/Y < 0 not iSceenW/H
Thank you, I fixed that so now it is working
Need help on something else now though. How would I add to that code to also detect where the pong racket is to bounce the ball from it when it collides?

My idea was something along these lines but I know it will just detect the value of the racket on the Y axis and bounce the ball on the X axis where that number may be on the screen.

1
2
3
4
if(iPongBallX + iPongBallW > iScreenW || iPongBallX < 0 || iPongBallX + iPongBallW == iPlayerTwoY )
		{
			iBallVelocityX *= -1;
		}
Topic archived. No new replies allowed.