急需贪吃蛇的设计改进思想

来源:百度知道 编辑:UC知道 时间:2024/07/16 05:04:04
要速度

给你个无任何控件的源代码,,,,,,, 你复制以下代码到你窗体下,按F5就行了
具体的设计思想,,自己分析吧!

'贪吃蛇代码(无控件、全代码)

Private WithEvents Timer1 As Timer
Private WithEvents Label1 As Label
Dim GFangXiang 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
If KeyCode = 27 Then End 'ESC退出
If KeyCode = 32 Then
If Timer1.Enabled = True Then '空格暂停
Timer1.Enabled = False
Label1.Visible = True
Else '空格开始
Timer1.Enabled = True
Label1.Visible = False
End If
End If
C = UBound(She)
If GFangXiang = True Then Exit Sub
Select Case KeyCode