5 Line1.X1 pointy Rnd Line2.Y2 - Line2.Y1 5 Line2.Y1 Shape2.Left pointx Shape2.Top pointy Shape2.FillColor RGBRnd 255 Rnd 255 Rnd 255 Shape2.Visible True Timer2.Interval 5000 End Sub Private Sub Timer3_Timer p1 p1 1 p p 1 Dim i As Integer If p Mod 2 1 Then For i 0 To maxlong Step 1 Shape1i.Visible False Next i Else For i 0 To maxlong Step 1 Shape1i.Visible True Next i End If If p1 6 Then Timer3.Enabled False MsgBox 结束游戏 End If Screen.MousePointer vbArrow End Sub Private Sub Toolbar1_ButtonClickByVal Button As MSComCtlLib.Button Select Case Button.Key Case start Call start_Click Case stop Call stop_game Case gogo Call start_game Case mm Static picture As Integer picture picture 1 Mod 4 If picture 0 Then FrmTCS.picture LoadPicture Exit Sub End If Dim s1 As String s1 bj picture .jpg FrmTCS.picture LoadPictureApp.Path s1 Case overgame Call end_game Case kuai Call nd2_game End Select End Sub 贪吃蛇模块 Public Runway As Integer 标明蛇移动的方向 初始化为 0左 Public p As Integer Public p1 As Integer Public Runstep As Integer 蛇头的宽度 Public maxlong As Integer 蛇的长度 初始化为3 Public Type str_snake_point 记录蛇的位置 x As Integer y As Integer End Type Public snake_init0 To 3 As str_snake_point 初始化记录蛇的位置 Public snake_point As str_snake_point 记录蛇移动时的坐标 该动态数组保存蛇暂停时的位置 Public snake_stopX As Integer Public snake_stopY As Integer Public snake_stop As str_snake_point 该动态数组保存蛇暂停时的位置 Public m_game As Integer 标明游戏关数 Public score As Integer 分数的记录 Public time1 As Integer Public Sub init_game 初始化游戏 Timer1.Enabled True Timer2.Enabled True ReDim snake_stopX0 To maxlong ReDim snake_stopY0 To maxlong MsgBox StrLBoundsnake_stopX MsgBox StrUBoundsnake_stopX Dim i As Integer ReDim sanke_stop0 To maxlong For i 0 To maxlong Step 1 If i 4 Then 把加载的控件卸载 Unload FrmTCS.Shape1i End If If i Form1.Line5.Y1 And _ Form1.Shape10.Top Form1.Line5.Y2 Then Form1.Timer1.Enabled False Form1.Timer2.Enabled False Form1.Timer3.Enabled True End If End If End Sub Public Sub group_snake Set frm Form1 If FrmTCS.Shape2.Left FrmTCS.Shape1i.Left And _ FrmTCS.Shape2.Left FrmTCS.Shape1i.Left FrmTCS.Shape10.Width And _ FrmTCS.Shape2.Top FrmTCS.Shape1i.Top And _ FrmTCS.Shape2.Top FrmTCS.Shape1i.Top FrmTCS.Shape1i.Height Then 向左吃食物满足上面条件 既吃到食物 FrmTCS.Shape2.Visible False maxlong maxlong 1 蛇身加1 Load FrmTCS.Shape1maxlong 加载一个数组控件 初始化位置 FrmTCS.Shape1maxlong.Left FrmTCS.Shape1maxlong - 1.Left FrmTCS.Shape1maxlong - 1.Width FrmTCS.Shape1maxlong.Top FrmTCS.Shape1maxlong - 1.Top FrmTCS.Shape1maxlong - 1.Height Randomize FrmTCS.Shape1maxlong.FillColor RGBRnd 255 Rnd 255 Rnd 255 FrmTCS.Shape1maxlong.Shape 0 FrmTCS.Shape1maxlong.Visible True score score 10 FrmTCS.Labelscore.Caption score End If If score 200 Then m_game m_game 1 FrmTCS.Timer1.Enabled False FrmTCS.Timer2.Enabled False MsgBox 恭喜你闯过第 m_game - 1 关 按回车键 开始下一关 64 score 0 Call init_game time1 FrmTCS.Timer1.Interval - m_game 15 FrmTCS.Timer2.Interval FrmTCS.Timer2.Interval - m_game 400 If time1