急!VB高手请进!求VB贪吃蛇代码(分由你说:只要够!)

来源:百度知道 编辑:UC知道 时间:2024/05/06 20:40:36
游戏结束要现出成绩的!
不要是全屏最好!
谢谢……

分数最多可能只能追加50分。。~~呵呵~
不过我可以给出你思路。:
在窗体上随机坐标出现图形A,程序不停的检测方向键上下左右 来控制由图形A累加起来的图形B。timer控件控制图形B的移动速度(游戏难度),当图形B碰到图形A时,图形B长度+1,图形A消失,然后再次在下一个随机坐标点出现图形A,如此反复进行。当图形B碰到窗体边缘时,~~ Game Over.. 同时出现图形B由多少个图形A组成(也就是成绩)

给个100分就行了。
把代码复制到空窗体中按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