Hi there,

I'm having a bit of trouble with collision detection. I've written a pong game and so far I've got the ball bouncing around the screen and the paddles moving up and down. I can't seem to get the ball to bounce off the paddles. I did a search and found other threads with snipets of code but can't get them to work with what I've already done.

This is the code I've used for the bouncing ball:

Dim RtnValue As Long
'Erase Ball
RtnValue = BitBlt(picField.hDC, BallX, BallY, picBall.ScaleWidth, picBall.ScaleHeight, picBlank.hDC, CLng(0), CLng(0), SRCCOPY)
'Compute Ball position / Check for bounces
BallX = BallX + BallXDir * BallXSpd
BallY = BallY + BallYDir * BallYSpd
If BallX < 0 Then
BallX = 0
BallXDir = 1
RtnValue = sndPlaySound(Bounce, SND_FILENAME Or SND_ASYNC)
lblScore2.Caption = Str(Val(lblScore2.Caption) + 1)
ElseIf BallX + picBall.ScaleWidth > picField.ScaleWidth Then
BallX = picField.ScaleWidth - picBall.ScaleWidth
BallXDir = -1
RtnValue = sndPlaySound(Bounce, SND_FILENAME Or SND_ASYNC)
lblScore1.Caption = Str(Val(lblScore1.Caption) + 1)
End If
If BallY < 0 Then
BallY = 0
BallYDir = 1
RtnValue = sndPlaySound(Bounce, SND_FILENAME Or SND_ASYNC)
ElseIf BallY + picBall.ScaleHeight > picField.ScaleHeight Then
BallY = picField.ScaleHeight - picBall.ScaleHeight
BallYDir = -1
RtnValue = sndPlaySound(Bounce, SND_FILENAME Or SND_ASYNC)
End If
RtnValue = BitBlt(picField.hDC, BallX, BallY, picBall.ScaleWidth, picBall.ScaleHeight, picBall.hDC, CLng(0), CLng(0), SRCCOPY)


picPaddle1 is on the left and picPaddle2 is on the right.

I'm sure it's easy to do, but I'm a beginner and I need it explained in "Dummy" terms.

Thanks.