Best collision code in VB

HWwizzard

Beta member
Messages
4
This is my current code:
If pongBall.Bounds.Right >= paddleRight.Bounds.Left And pongBall.Bounds.Right < (paddleRight.Bounds.Left + 20) And pongBall.Bounds.Bottom > paddleRight.Bounds.Top And pongBall.Bounds.Top < paddleRight.Bounds.Bottom Then

End if

is there a better way to do it... this is so long and painful to repeat... does anyone know a better / shorter way to code it?
 
Whether there's a shorter way of doing it or not, you shouldn't be repeating that line of code at all - you should farm it out into a separate function, then just call that each time you need it.
 
i have to repeat it for each moving object that i want to include... so that means copy and paste and then changing the variables to new object... i was wonder how to shorten it or make all of the moving objects follow the same code
 
Back
Top Bottom