What I'm trying to do (for a pong game), is what the original creator of pong did. What he did was, he divided the paddle into eight segments to change the ball's angle of return. Now I only want 3 as it's more simplistic, among other reasons. But my problem is, getting to see if the ball intersects with an area of another picturebox.
My user's picturebox has a height of 120, so I want to see if the ball picturebox intersects with the area of the user's picturebox's height to the user's picturebox's height - 40.
I know that was probably a really, really confusing question, because even I confused myself. If you need more details, I'll be happy to supply them.
7 Replies - 1041 Views - Last Post: 16 December 2011 - 03:41 PM
#1
Problem: If a picturebox intersects with a specific area of another.
Posted 12 December 2011 - 10:45 AM
Replies To: Problem: If a picturebox intersects with a specific area of another.
#2
Re: Problem: If a picturebox intersects with a specific area of another.
Posted 12 December 2011 - 11:02 AM
Yeah.. not a hundred percent sure what you are asking for. Can you throw us a quick image of what you want done?
#3
Re: Problem: If a picturebox intersects with a specific area of another.
Posted 12 December 2011 - 11:03 AM
You can check the PB.ClientRectangle.IntersectWith(<another rectangle>). You could also do the whole thing with rectangles and no PB's if you wanted a bit more challenge later. Kind of a pure graphics version. Sorry I am a huge graphics guy.
#4
Re: Problem: If a picturebox intersects with a specific area of another.
Posted 14 December 2011 - 10:15 AM
_HAWK_, on 12 December 2011 - 11:03 AM, said:
You can check the PB.ClientRectangle.IntersectWith(<another rectangle>). You could also do the whole thing with rectangles and no PB's if you wanted a bit more challenge later. Kind of a pure graphics version. Sorry I am a huge graphics guy.
The problem is not getting it intersecting with another rectangle, but getting it to intersect with a specific part of that triangle.

Basically, I want to see if the pong ball intersects with the part of the user's paddle that i made a square around.
Also, sorry for the late reply. I've been really busy lately.
#5
Re: Problem: If a picturebox intersects with a specific area of another.
Posted 14 December 2011 - 12:43 PM
That would be a math thing. Once you have determined they have connected you figure out where it struck the paddle.
This post has been edited by _HAWK_: 14 December 2011 - 07:43 PM
#6
Re: Problem: If a picturebox intersects with a specific area of another.
Posted 16 December 2011 - 10:34 AM
#7
Re: Problem: If a picturebox intersects with a specific area of another.
Posted 16 December 2011 - 11:16 AM
Logic:
1) detect collision, skip all if false
2) variable to hold the the paddle top integer
3) create the zones of the paddle -> height / number of zones
4) determine the middle of the ball rect - integer variable,
5) loop thru the number of zones where you test the lower and upper numbers and if the middle variable is between them
6) apply the angle base on which zone returned a true result
Loop(the harder part):
You still need to create the variable above - just an example.
1) detect collision, skip all if false
2) variable to hold the the paddle top integer
3) create the zones of the paddle -> height / number of zones
4) determine the middle of the ball rect - integer variable,
5) loop thru the number of zones where you test the lower and upper numbers and if the middle variable is between them
6) apply the angle base on which zone returned a true result
Loop(the harder part):
Dim zoneTop As Integer = paddleTop
For z As Integer = 1 To zoneCount
Select Case z
Case 1 'top
If ballMiddle < zoneTop + zoneHt Then
'adjust angle for top zone
End If
Case 2 To zoneCount - 1
If ballMiddle > zoneTop AndAlso < zoneTop + zoneHt
'adjust angle for a middle zone
End If
Case zoneCount
If ballMiddle > zoneTop + zoneHt
'adjust angle for bottom zone
End If
End Select
zoneTop += zoneHt 'increment the zone ht
Next
You still need to create the variable above - just an example.
This post has been edited by _HAWK_: 16 December 2011 - 11:21 AM
#8
Re: Problem: If a picturebox intersects with a specific area of another.
Posted 16 December 2011 - 03:41 PM
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote







|