Results 1 to 3 of 3

Thread: Any Bouncing Ball Tutorials?

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2006
    Posts
    34

    Thumbs up 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.

  2. #2
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051

    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.


  3. #3

    Thread Starter
    Member
    Join Date
    Jun 2006
    Posts
    34

    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:
    1. Private Sub BallPhysics()
    2.         BallBottom = Ball.Top + Ball.Height
    3.         BallTop = Ball.Top
    4.         BallRight = Ball.Left + Ball.Width
    5.         BallLeft = Ball.Left
    6.         ThingBottom = Pad.Top + Pad.Height
    7.         ThingTop = Pad.Top
    8.         ThingRight = Pad.Left + Pad.Width
    9.         ThingLeft = Pad.Left
    10.         If BallBottom >= ThingTop AndAlso BallLeft >= ThingLeft AndAlso BallRight <= ThingRight Then
    11.             up = True
    12.             speed = Ball.Top - Ball.Top * 2
    13.  
    14.         End If
    15.     End Sub
    And now here is my Timer 1 tick event:
    VB Code:
    1. Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    2.         Label1.Text = speed
    3.         If up = False Then
    4.             Ball.Top = Ball.Top + speed
    5.             BallPhysics()
    6.         ElseIf up = True Then
    7.             Ball.Top = Ball.Top + speed
    8.         End If
    9.     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
  •  



Click Here to Expand Forum to Full Width