Dim xxx As Single
Dim yyy As Single
Dim fartx As Single
Dim farty As Single
Dim incx As Single
Dim incy As Single
Dim maxx As Single
Dim maxy As Single
Dim avstandx As Single
Dim avstandy As Single
Private Sub Form_Load()
PSet (Command1.Left, Command1.Top), QBColor(15)
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
Command1.Left = xxx
Command1.Top = yyy
End If
If Button = 2 Then
Cls
PSet (Command1.Left, Command1.Top)
End If
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
xxx = X
yyy = Y
End Sub
Private Sub Timer1_Timer()
Line -(Command1.Left, Command1.Top), QBColor(15)
'Ta bord raden ovan ifall du inte vill att den ska måla spår
'efter sig.
avstandx = Abs(xxx - Command1.Left)
avstandy = Abs(yyy - Command1.Top)
incx = (avstandx * 0.009)
incy = (avstandy * 0.009)
If xxx > Command1.Left Then fartx = fartx + incx
If xxx < Command1.Left Then fartx = fartx - incx
If yyy > Command1.Top Then farty = farty + incy
If yyy < Command1.Top Then farty = farty - incy
If fartx > 0 Then fartx = fartx - 3
If fartx < 0 Then fartx = fartx + 3
If farty > 0 Then farty = farty - 3
If farty < 0 Then farty = farty + 3
If incx > 10 Then incx = 10
If incy > 10 Then incy = 10
If incx < -10 Then incx = -10
If incy < -10 Then incy = -10
Command1.Left = Command1.Left + fartx
Command1.Top = Command1.Top + farty
Randomize Timer
Do
kaosx = (Rnd * 1) - 0.5
kaosy = (Rnd * 1) - 0.5
Loop Until kaosx <> 0 And kaosy <> 0
End Sub