1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
|
Private x, y, ax, ay, c, coefd As Integer
Private i, t, b As Long
Private arret, quit As Boolean
Private Sub Command1_Click()
arret = False
Do While (x > 50) And (x < (Picture1.ScaleWidth - 50)) And (y > 50) And (y < (Picture1.ScaleHeight - 50)) And (arret = False) And (quit = False)
Picture1.FillColor = vbWhite
Picture1.Line (0, 0)-Step(ScaleWidth, ScaleHeight), , B
Picture1.FillColor = vbBlack
Picture1.Circle (x, y), 50, black
For i = 0 To t
Next i
Select Case coefd
Case 1
x = x + c
y = ax * x + b
Case 2
y = y + c
x = (y - b) * ay
End Select
DoEvents
If (x <= 50) Or (x >= (Picture1.ScaleWidth - 50)) Then
Select Case coefd
Case 1
ax = -ax
b = y - ax * x
c = -c
x = x + c
y = ax * x + b
Case 2
ay = -ay
b = y - (x / ay)
y = y + c
x = (y - b) * ay
End Select
End If
If (y <= 50) Or (y >= (Picture1.ScaleHeight - 50)) Then
Select Case coefd
Case 1
ax = -ax
b = y - ax * x
x = x + c
y = ax * x + b
Case 2
ay = -ay
b = y - (x / ay)
c = -c
y = y + c
x = (y - b) * ay
End Select
End If
Loop
If quit = True Then
Unload Form1
End If
End Sub
Private Sub Command2_Click()
arret = True
End Sub
Private Sub Command3_Click()
quit = True
Unload Form1
End Sub
Private Sub Form_Activate()
Picture1.FillColor = vbBlack
Picture1.Circle (x, y), 50, black
End Sub
Private Sub Form_Load()
Randomize
x = Int((Picture1.ScaleWidth - 100 + 1) * Rnd + 50)
y = Int((Picture1.ScaleHeight - 100 + 1) * Rnd + 50)
coefd = Int(2 * Rnd + 1)
ax = Int((6 - 1) * Rnd + 1)
ay = Int((6 - 1) * Rnd + 1)
c = 1
Select Case coefd
Case 1
Select Case ax
Case 1
t = 30000
Case 2
t = 47440
Case 3
t = 67090
Case 4
t = 87470
Case 5
t = 108180
End Select
Case 2
Select Case ay
Case 1
t = 30000
Case 2
t = 47440
Case 3
t = 67090
Case 4
t = 87470
Case 5
t = 108180
End Select
End Select
Select Case coefd
Case 1
b = y - ax * x
Case 2
b = y - (x / ay)
End Select
End Sub |
Partager