try this see if it works for you
Code:
Sub MovePic()
Dim x As Single, y As Single, angle As Single, vangle As Single, sCount As Single, Speed As Single
'CenterPic
Me.picJackpot.ZOrder 0
Speed = 0.1 'between 0.1 - 100 ... if you want you can put more but thats insane!
angle = Rnd * 6.283
x = picJackpot.Left: y = picJackpot.Top
Do While mStopJackPot = False
DoEvents
sCount = sCount + 1
If sCount > 2500 / Speed Then
sCount = 0
If Rnd < 0.1 Then vangle = (Rnd - 0.5) * 0.5 'Change direction velocity randomly 10%chance
angle = angle + (vangle + 6.283) Mod 6.283 'change direction
x = x + Cos(angle) * 10 'move position
y = y + Sin(angle) * 10
If x <= 0 Then x = 0
If x >= (Form1.Width - picJackpot.Width - 240) Then x = (Form1.Width - picJackpot.Width - 240)
If y <= 0 Then y = 0
If y >= (Form1.Height - picJackpot.Height - 560) Then y = (Form1.Height - picJackpot.Height - 560)
picJackpot.Move x, y
End If
Loop
End Sub
or also like this
Code:
Sub MovePic(Speed As Single)
Dim x As Single, y As Single, angle As Single, vangle As Single, sCount As Single
'CenterPic
picJackpot.ZOrder 0
angle = Rnd * 6.283
x = picJackpot.Left: y = picJackpot.Top
Do While mStopJackPot = False
DoEvents
sCount = sCount + 1
If sCount > 2500 / Speed Then
sCount = 0
If Rnd < 0.1 Then vangle = (Rnd - 0.5) * 0.5 'Change direction velocity randomly 10%chance
angle = angle + (vangle + 6.283) Mod 6.283 'change direction
x = x + Cos(angle) * 10 'move position
y = y + Sin(angle) * 10
If x <= 0 Then x = 0
If x >= (Form1.Width - picJackpot.Width - 240) Then x = (Form1.Width - picJackpot.Width - 240)
If y <= 0 Then y = 0
If y >= (Form1.Height - picJackpot.Height - 560) Then y = (Form1.Height - picJackpot.Height - 560)
picJackpot.Move x, y
End If
Loop
End Sub
Private Sub Form_Load()
MovePic 0.1 'Speed 'best between 0.1 - 100 ... if you want you can put more but thats insane!
End Sub
Private Sub Command1_Click()
MovePic 0.1
'Speed 'best between 0.1 - 100 ... if you want you can put more but thats insane!
End Sub