|
-
Oct 30th, 2002, 05:50 PM
#1
Thread Starter
Fanatic Member
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
-
Oct 30th, 2002, 05:58 PM
#2
Fanatic Member
VB Code:
Private Sub TmrRight_Timer()
Static NB as integer
If NB = 4 then
ImgBall.Left = ImgBall.Left + 200
If ImgBall.Left >= (ImgWall(1).Left - 375) Then
TmrLeft.Enabled = True
TmrRight.Enabled = False
End If
Else
NB = NB +1
End Sub
Private Sub TmrLeft_Timer()
ImgBall.Left = ImgBall.Left - 200
If ImgBall.Left = (ImgWall(0).Left + 375) Then
TmrRight.Enabled = True
TmrLeft.Enabled = False
End If
NB = NB+1
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
-
Oct 30th, 2002, 06:08 PM
#3
Thread Starter
Fanatic Member
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
-
Oct 30th, 2002, 06:18 PM
#4
Thread Starter
Fanatic Member
Wow making a ball bounce is the hardest thing you can do in VB~@!!#
-
Oct 30th, 2002, 06:24 PM
#5
Fanatic Member
Sorry, my code had lots of bugs
I hadn't tested it, now I did:
VB Code:
Private Sub TmrRight_Timer()
Shape1.Left = Shape1.Left + 200
If Shape1.Left >= 3600 Then
TmrLeft.Enabled = True
TmrRight.Enabled = False
End If
End Sub
Private Sub TmrLeft_Timer()
Shape1.Left = Shape1.Left - 200
If Shape1.Left = 0 Then
TmrRight.Enabled = True
TmrLeft.Enabled = False
End If
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
-
Oct 30th, 2002, 07:01 PM
#6
Thread Starter
Fanatic Member
-
Oct 30th, 2002, 07:04 PM
#7
Fanatic Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|