I'm doing some follow-up work on a project that I have and it moves a panel(or picturebox) that's moving inside a panel. The code goes something along the lines of this inside a timer:
If it collides with the paddle(progressbar) I switch the x and y coordinates:
The problem came when it hits the border of it's parent panel. If I try the intersectswith method, it's allways intersecting with the parent panel because it's inside of the panel! So my work around in the past was to just add 4 picturesboxes and dock one to each side. Then if ball hit one of those panels then I would reverse either the x, y depending on which picturebox it hit. Now my problem is, I changed the region of the parent panel. The sides are zig-zagged and there are slots at the bottom(Plinko!). My question is how can I detect where the ball hit wall and change the x, y that way?
Code:
Static x as Integer = -1
Static y as Integer = -1
pnl_Ball.Left += x
pnl_Ball.Top += y
Code:
If pnl_Ball.Bounds.IntersectsWith(paddle.Bounds) Then
x = -x
y = -y
End If