Need Help W/ Random Movement

mr_mich
03-01-2002, 01:34 PM
Private Sub RandMov(Picture As PictureBox)

Dim Bounce As Boolean

If Picture.Top < 1000 Then
Bounce = True
End If

If Picture.Top >= 300 Then
If Bounce <> True Then
If Picture.Left >= 8640 And Picture.Top >= 6240 Then
Picture.Move Picture.Left - Rand(FarcLo, 300), Picture.Top - Rand(FarcLo, 300)
ElseIf Picture.Top <= 1000 Then
Picture.Move Picture.Left + 0, Picture.Top + 1400
ElseIf Picture.Left <= 1000 Then
Picture.Move Picture.Left + 1000
ElseIf Picture.Left <= 120 And Picture.Top >= 6240 Then
Picture.Move Picture.Left + Rand(FarcLo, 300), Picture.Top - Rand(FarcLo, 300)
ElseIf Picture.Left <= 120 And Picture.Top <= 300 Then
Picture.Move Picture.Left + Rand(FarcLo, 300), Picture.Top + Rand(FarcLo, 300)
ElseIf Picture.Left >= 8640 And Picture.Top <= 300 Then
Picture.Move Picture.Left - Rand(FarcLo, 300), Picture.Top + Rand(FarcLo, 300)
Else: Picture.Move Picture.Left - Rand(NFarcLo + 100, 1000), Picture.Top - Rand(NFarcLo + 100, 1000)
End If
Else: Picture.Move Picture.Left - 500
End If
Else: Picture.Move Picture.Left + 0, Picture.Top + 400
End If

End Sub

Squirm
03-01-2002, 04:34 PM
And your question is....... ??

mr_mich
03-01-2002, 05:34 PM
What's wrong in my code that makes the guy get stuck in certain places.

Instead of just asking for code, I'm asking how I can see mistakes instead of repeatedly coming back here for help and annoying the smart people like you.

Osiris
03-01-2002, 10:01 PM
even though its hard to figure out what you're trying to do
with just code i tried to follow it, but this function or sub keeps
popping up:

Rand(FarcLo, 300)

after that i just gave up, cause i have no idea what you are
trying to do there buddy, i might be wrong but your trying to
explain a blind man colors

Robby
03-02-2002, 12:14 AM
Maybe you can assign Rand(FarcLo, 300) to a variable so it comes up the same every time.

Squirm
03-02-2002, 07:52 AM
What I can see, is once the Picture.Top gets to between 300 and 1000, it will get stuck in there, since bounce will always be True and that means the only piece of code that comes into play is:

Picture.Move Picture.Left - 500

So the picture will just move to the left by 500 each time but never escape this 300-1000 height area.

mr_mich
03-02-2002, 01:23 PM
Sorry about the rand thing.

Rand is a function I wrote that gets a random number in a range of numbers. EX- Rand(NFarcLo, 300) gets a number between the value of NFarcLo and 300.

Squirm, I fixed it so now it says:

If Bounce <> True Then

...

Else: Picture.Move Picture.Left + 0, Picture.Top + 500

But now it goes futher to the left and stuck, and I still can't see what's wrong.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum