[求助] 大家能否帮我注释下?
贪吃蛇网上下的源码,可是看不懂,大家能否帮我注释下呢?
Dim s() As Integer
Dim dz(1) As Integer
Dim fx As Byte 'fx是什么?
Const sb = 0
Const xb = 1
Const zb = 2
Const yb = 3
Const z = 10
Const d = 10
Const k = 10
Const g = 10
Const hg = 20
Const sg = 20
Private Sub Form_Load()
ReDim s(1, 0)
hgz
s(0, 0) = 1
s(1, 0) = 1
fx = xb
bean
End Sub
Private Sub hgz()
Dim l As Integer
Dim l1 As Integer
For l = 0 To hg
For l1 = 0 To sg
Line (l * k + z, l1 * g + d)-((l + 1) * k + z, (l1 + 1) * g + d), 0, B
Next
Next
End Sub
Private Sub bean()
Randomize
dz(0) = Int((hg + 1) * Rnd)
dz(1) = Int((sg + 1) * Rnd)
Line (dz(0) * k + z, dz(1) * g + d)-((dz(0) + 1) * k + z, (dz(1) + 1) * g + d), 65280, BF
End Sub
Private Sub Timer1_Timer()
Dim n As Integer
Cls
hgz
Line (dz(0) * k + z, dz(1) * g + d)-((dz(0) + 1) * k + z, (dz(1) + 1) * g + d), 65280, BF
For n = UBound(s, 2) To 1 Step -1 '这个for 循环是什么作用?下标已经越界了,有什么意义?
s(0, n) = s(0, n - 1)
s(1, n) = s(1, n - 1)
Next
Select Case fx '这里又是怎么判别的?
Case sb
s(1, 0) = s(1, 0) - 1
If s(1, 0) < 0 Then over
Case xb
s(1, 0) = s(1, 0) + 1
If s(1, 0) > sg Then over
Case zb
s(0, 0) = s(0, 0) - 1
If s(0, 0) < 0 Then over
Case yb
s(0, 0) = s(0, 0) + 1
If s(0, 0) > hg Then over
End Select
If s(0, 0) = dz(0) And s(1, 0) = dz(1) Then
ReDim Preserve s(1, UBound(s, 2) + 1)
Select Case fx
Case sb
s(1, UBound(s, 2)) = s(1, 0) + 1
s(0, UBound(s, 2)) = s(0, 0)
Case xb
s(1, UBound(s, 2)) = s(1, 0) - 1
s(0, UBound(s, 2)) = s(0, 0)
Case zb
s(0, UBound(s, 2)) = s(0, 0) + 1
s(1, UBound(s, 2)) = s(1, 0)
Case yb
s(0, UBound(s, 2)) = s(0, 0) - 1
s(1, UBound(s, 2)) = s(1, 0)
End Select
bean
End If
Line (s(0, 0) * k + 2 + z, s(1, 0) * g + 2 + d)-((s(0, 0) + 1) * k - 2 + z, (s(1, 0) + 1) * g - 2 + d), 255, BF
For n = 1 To UBound(s, 2)
Line (s(0, n) * k + 2 + z, s(1, n) * g + 2 + d)-((s(0, n) + 1) * k - 2 + z, (s(1, n) + 1) * g - 2 + d), 255, BF
If s(0, 0) = s(0, n) And s(1, 0) = s(1, n) Then over
Next
End Sub
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case 38 ' 38为键盘的上箭头KeyCode值
If fx <> xb Then '这是什么意思?有什么作用?
fx = sb
End If
Case 40 '40为键盘的下箭头KeyCode值
If fx <> sb Then
fx = xb
End If
Case 37 '37为键盘的左箭头KeyCode值
If fx <> yb Then
fx = zb
End If
Case 39 '39为键盘的右箭头KeyCode值
If fx <> zb Then
fx = yb
End If
End Select
End Sub
Private Sub over()
Timer1.Enabled = False
MsgBox "哈哈~~~~,你完了"
End Sub
[[it] 本帖最后由 Sally_SJL 于 2008-3-19 11:13 编辑 [/it]]