Dim FangXiang As Boolean
Dim HWB As Single
Dim She() As ShenTi
Dim X As Long, Y As Long
Dim ZhuangTai(23, 23) As Long
Private Type ShenTi
F As Long
X As Long
Y As Long
End Type
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Dim C As Long
C = UBound(She)
If FangXiang = True Then Exit Sub
Select Case KeyCode
Case 37
If She(C).F = 2 Then Exit Sub
She(C).F = 0
FangXiang = True
Case 38
If She(C).F = 3 Then Exit Sub
She(C).F = 1
FangXiang = True
Case 39
If She(C).F = 0 Then Exit Sub
She(C).F = 2
FangXiang = True
Case 40
If She(C).F = 1 Then Exit Sub
She(C).F = 3
FangXiang = True
End Select
End Sub
Private Sub Form_Load()
I = MsgBox("欢迎进入贪吃蛇游戏是否开始", 49, "提示")
Me.AutoRedraw = True
Me.WindowState = 0
a = Val(InputBox("请输入你设定的速度(1至9)", "速度设置"))
Timer1.Interval = 1000 - a * 100
Timer1.Enabled = True
ChuShiHua
End Sub
Private Sub Form_Resize()
Dim HWB As Single
Dim She() As ShenTi
Dim X As Long, Y As Long
Dim ZhuangTai(23, 23) As Long
Private Type ShenTi
F As Long
X As Long
Y As Long
End Type
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Dim C As Long
C = UBound(She)
If FangXiang = True Then Exit Sub
Select Case KeyCode
Case 37
If She(C).F = 2 Then Exit Sub
She(C).F = 0
FangXiang = True
Case 38
If She(C).F = 3 Then Exit Sub
She(C).F = 1
FangXiang = True
Case 39
If She(C).F = 0 Then Exit Sub
She(C).F = 2
FangXiang = True
Case 40
If She(C).F = 1 Then Exit Sub
She(C).F = 3
FangXiang = True
End Select
End Sub
Private Sub Form_Load()
I = MsgBox("欢迎进入贪吃蛇游戏是否开始", 49, "提示")
Me.AutoRedraw = True
Me.WindowState = 0
a = Val(InputBox("请输入你设定的速度(1至9)", "速度设置"))
Timer1.Interval = 1000 - a * 100
Timer1.Enabled = True
ChuShiHua
End Sub
Private Sub Form_Resize()