Go Back   Computer Forums > General Computing > Programming
Click Here to Login
Join Computer forums Today


Reply
 
Thread Tools Search this Thread Display Modes
 
Old 01-26-2010, 04:50 PM   #1
Beta Member
 
Join Date: Jan 2010
Posts: 4
Default Best collision code in VB

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?
__________________

HWwizzard is offline   Reply With Quote
Old 01-26-2010, 05:05 PM   #2
Site Team
 
berry120's Avatar
 
Join Date: Jul 2009
Location: England, UK
Posts: 3,425
Default Re: Best collision code in VB

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.
__________________

berry120 is offline   Reply With Quote
Old 01-26-2010, 05:30 PM   #3
Beta Member
 
Join Date: Jan 2010
Posts: 4
Default Re: Best collision code in VB

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
HWwizzard is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



All times are GMT -5. The time now is 05:53 PM.


Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0