|
-
Jun 23rd, 2006, 02:08 PM
#1
Thread Starter
Member
Any Bouncing Ball Tutorials?
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.
-
Jun 23rd, 2006, 02:38 PM
#2
Not NoteMe
Re: Any Bouncing Ball Tutorials?
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.
Quotes:
"I am getting better then you guys.." NoteMe, on his leet english skills.
"And I am going to meat her again later on tonight." NoteMe
"I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
"my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
Have I helped you? Please Rate my posts. 
-
Jun 23rd, 2006, 03:50 PM
#3
Thread Starter
Member
Re: Any Bouncing Ball Tutorials?
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:
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
And now here is my Timer 1 tick event:
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
Please help!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|