Results 1 to 7 of 7

Thread: Making the circle bounce off the side

  1. #1

    Thread Starter
    Fanatic Member scr0p's Avatar
    Join Date
    Oct 2002
    Location
    VA
    Posts
    720

    Making the circle bounce off the side

    I have a circle shape. I want it to hit the left side, then go to the right side, hit the right side, and then go left, I can get it to go left and stop, but not go back to the right. I am using object.move meth0d

  2. #2
    Fanatic Member Alien_poo's Avatar
    Join Date
    Jan 2002
    Location
    Canada
    Posts
    668
    VB Code:
    1. Private Sub TmrRight_Timer()
    2.         Static NB as integer
    3.         If NB = 4 then
    4.           ImgBall.Left = ImgBall.Left + 200
    5.           If ImgBall.Left >= (ImgWall(1).Left - 375) Then
    6.               TmrLeft.Enabled = True
    7.               TmrRight.Enabled = False
    8.           End If
    9.         Else
    10.         NB = NB +1
    11. End Sub
    12.  
    13. Private Sub TmrLeft_Timer()
    14.         ImgBall.Left = ImgBall.Left - 200
    15.         If ImgBall.Left = (ImgWall(0).Left + 375) Then
    16.             TmrRight.Enabled = True
    17.             TmrLeft.Enabled = False
    18.         End If
    19.         NB = NB+1
    20. End sub

    Dont know if this will help... it's not using Object.move method, but It still works:
    You need to add:
    2 Images (the 2 walls) of 375 width
    2 timers
    Another Image (the ball that will bounce)
    "A RESPECTED scientist has put forward the stunning - if unsavoury - possibility that humans are descended from sewage dumped overboard by aliens."
    "First we read that we are the creation of God, then scientists say we are descended from apes. Now they say we're some sort of alien poo. How much further can we sink?"
    - Robert Matthews, Science Correspondent

  3. #3

    Thread Starter
    Fanatic Member scr0p's Avatar
    Join Date
    Oct 2002
    Location
    VA
    Posts
    720
    I cant get it to work, I want the ball to bounce between the 2 walls, I will work on this to see what I come up with though, thanks

  4. #4

    Thread Starter
    Fanatic Member scr0p's Avatar
    Join Date
    Oct 2002
    Location
    VA
    Posts
    720
    Wow making a ball bounce is the hardest thing you can do in VB~@!!#

  5. #5
    Fanatic Member Alien_poo's Avatar
    Join Date
    Jan 2002
    Location
    Canada
    Posts
    668

    Sorry, my code had lots of bugs

    I hadn't tested it, now I did:

    VB Code:
    1. Private Sub TmrRight_Timer()
    2.         Shape1.Left = Shape1.Left + 200
    3.         If Shape1.Left >= 3600 Then
    4.             TmrLeft.Enabled = True
    5.             TmrRight.Enabled = False
    6.         End If
    7. End Sub
    8.  
    9. Private Sub TmrLeft_Timer()
    10.         Shape1.Left = Shape1.Left - 200
    11.         If Shape1.Left = 0 Then
    12.             TmrRight.Enabled = True
    13.             TmrLeft.Enabled = False
    14.         End If
    15. End Sub

    you need 2 timers, 1 shape
    the code will not make your shape stop after 4 bounces though...

    P.S. THIS CODE WILL MAKE YOUR CIRCLE BOUNCE WHEN IT REACHES LEFT: 3600
    "A RESPECTED scientist has put forward the stunning - if unsavoury - possibility that humans are descended from sewage dumped overboard by aliens."
    "First we read that we are the creation of God, then scientists say we are descended from apes. Now they say we're some sort of alien poo. How much further can we sink?"
    - Robert Matthews, Science Correspondent

  6. #6

    Thread Starter
    Fanatic Member scr0p's Avatar
    Join Date
    Oct 2002
    Location
    VA
    Posts
    720
    this works, thanks!!

  7. #7
    Fanatic Member Alien_poo's Avatar
    Join Date
    Jan 2002
    Location
    Canada
    Posts
    668
    np, if you want me to make it stop after 4 bounces i can get it to work, just tell me if you need me to do this
    "A RESPECTED scientist has put forward the stunning - if unsavoury - possibility that humans are descended from sewage dumped overboard by aliens."
    "First we read that we are the creation of God, then scientists say we are descended from apes. Now they say we're some sort of alien poo. How much further can we sink?"
    - Robert Matthews, Science Correspondent

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