Does anyone here know of any bouncing ball collision detection tutorials for Visual Basic.Net 2003? If you do could you please tell me of them.
Printable View
Does anyone here know of any bouncing ball collision detection tutorials for Visual Basic.Net 2003? If you do could you please tell me of them.
A search on this forum for 'bounce ball' turned up some good results, while not tutorials they should give you the infomation you need. Note, that they're not VB.NET, but if you understand the language you should be able to write something pretty easily.
Just post back if you have any problems. :)
Thanks, I'll try that. But also I have tried something. I tried to make it so when my ball hits the Pad it calculates what the balls .Top value is and then it subtracts that value by its .Top Value * 2 to make the .Top value a negative integer, this integer is stored in a variable called 'speed' but then when I write: Ball.Top = Ball.Top + speed , the ball goes flies upwards and off the screen extremely fast, I tried to figure out the problem so I made a label that displayed what my speed was and at first the label displayed the proper speed of the ball falling down: 5, but then when it hit the pad the ball went flying upwards and the speed label said: -378 ! Here is my code if it will help, here is the code for the BallPhysics Sub:
And now here is my Timer 1 tick event:VB Code:
Private Sub BallPhysics() BallBottom = Ball.Top + Ball.Height BallTop = Ball.Top BallRight = Ball.Left + Ball.Width BallLeft = Ball.Left ThingBottom = Pad.Top + Pad.Height ThingTop = Pad.Top ThingRight = Pad.Left + Pad.Width ThingLeft = Pad.Left If BallBottom >= ThingTop AndAlso BallLeft >= ThingLeft AndAlso BallRight <= ThingRight Then up = True speed = Ball.Top - Ball.Top * 2 End If End Sub
Please help!VB Code:
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick Label1.Text = speed If up = False Then Ball.Top = Ball.Top + speed BallPhysics() ElseIf up = True Then Ball.Top = Ball.Top + speed End If End Sub