VB制作贪吃蛇游戏

来源:百度知道 编辑:UC知道 时间:2024/06/25 18:39:00
制作的界面要求是棋盘状的就是有网格的,让蛇在上面走。还有怎么随机出现5个数字,吃掉数字使蛇增加相应的长度。急求谢了。
我只是要一个方法,说说就可以,具体的我自己去做,诚心的问,像2楼那样的别说话!

webdavx@163.com

把代码复制到空窗体中按F5运行即可。

Option Explicit

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
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
Case 37
If She(C).F = 2 Then Exit Sub
She(C).F = 0
GFangXiang = True
Case 38
If She(C).F = 3 Then Exit Su