📄 form1.frm
字号:
VERSION 5.00
Begin VB.Form Form1
AutoRedraw = -1 'True
Caption = "Form1"
ClientHeight = 3420
ClientLeft = 5040
ClientTop = 3720
ClientWidth = 3450
LinkTopic = "Form1"
ScaleHeight = 228
ScaleMode = 3 'Pixel
ScaleWidth = 230
Begin VB.Timer Timer1
Interval = 100
Left = 3120
Top = 600
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim s() As Integer
Dim dz(1) As Integer
Dim fx As Byte
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_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case 38
If fx <> xb Then
fx = sb
End If
Case 40
If fx <> sb Then
fx = xb
End If
Case 37
If fx <> yb Then
fx = zb
End If
Case 39
If fx <> zb Then
fx = yb
End If
End Select
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 Form_Load()
ReDim s(1, 0)
hgz
s(0, 0) = 1
s(1, 0) = 1
fx = xb
bean
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
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 over()
Timer1.Enabled = False
MsgBox "GameOver!"
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
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -