⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 贪食蛇.frm

📁 本文以电工学正弦理论为基础;以经典的自然采样法为依托;以电子变流技术为研究对象
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Form1"
   ClientHeight    =   7425
   ClientLeft      =   45
   ClientTop       =   435
   ClientWidth     =   9405
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   ScaleHeight     =   7425
   ScaleWidth      =   9405
   StartUpPosition =   3  '窗口缺省
   Begin VB.Timer Timer1 
      Interval        =   100
      Left            =   4320
      Top             =   6120
   End
   Begin VB.Shape shp 
      BackColor       =   &H00F97D4F&
      BackStyle       =   1  'Opaque
      BorderStyle     =   0  'Transparent
      Height          =   350
      Index           =   5
      Left            =   6600
      Shape           =   4  'Rounded Rectangle
      Top             =   5280
      Width           =   350
   End
   Begin VB.Shape shp 
      BackColor       =   &H00F97D4F&
      BackStyle       =   1  'Opaque
      BorderStyle     =   0  'Transparent
      Height          =   350
      Index           =   4
      Left            =   6600
      Shape           =   4  'Rounded Rectangle
      Top             =   5280
      Width           =   350
   End
   Begin VB.Shape shp 
      BackColor       =   &H00F97D4F&
      BackStyle       =   1  'Opaque
      BorderStyle     =   0  'Transparent
      Height          =   350
      Index           =   3
      Left            =   6600
      Shape           =   4  'Rounded Rectangle
      Top             =   5280
      Width           =   350
   End
   Begin VB.Shape shp 
      BackColor       =   &H00F97D4F&
      BackStyle       =   1  'Opaque
      BorderStyle     =   0  'Transparent
      Height          =   350
      Index           =   2
      Left            =   6600
      Shape           =   4  'Rounded Rectangle
      Top             =   5280
      Width           =   350
   End
   Begin VB.Shape shp 
      BackColor       =   &H00F97D4F&
      BackStyle       =   1  'Opaque
      BorderStyle     =   0  'Transparent
      Height          =   350
      Index           =   1
      Left            =   6600
      Shape           =   4  'Rounded Rectangle
      Top             =   5280
      Width           =   350
   End
   Begin VB.Shape Shp1 
      BackColor       =   &H000000FF&
      BackStyle       =   1  'Opaque
      BorderStyle     =   0  'Transparent
      Height          =   350
      Left            =   4560
      Shape           =   2  'Oval
      Top             =   3960
      Width           =   350
   End
   Begin VB.Shape shp 
      BackColor       =   &H00F97D4F&
      BackStyle       =   1  'Opaque
      BorderStyle     =   0  'Transparent
      Height          =   350
      Index           =   0
      Left            =   2400
      Shape           =   2  'Oval
      Top             =   3000
      Width           =   350
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim temp, now As Integer
Dim goside As Integer
Dim rndint As Integer


Private Sub Command1_Click()
End
End Sub

Private Sub Combo1_Change()

End Sub

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyLeft Then
    If goside <> 3 Then
    goside = 1
    End If
ElseIf KeyCode = vbKeyUp Then
    If goside <> 2 Then
    goside = 0
    End If
ElseIf KeyCode = vbKeyRight Then
    If goside <> 1 Then
    goside = 3
    End If
ElseIf KeyCode = vbKeyDown Then
    If goside <> 0 Then
    goside = 2
    End If
ElseIf KeyCode = 27 Then
    End
ElseIf KeyCode = 32 Then
    If Timer1.Enabled = True Then
        Timer1.Enabled = False
    Else: Timer1.Enabled = True
    End If
End If
End Sub



Private Sub Form_Load()
Timer1.Interval = 120
goside = 3
now = 5
temp = 0
With Form1
    .Width = 6000
    .Height = 6000
End With
shp(0).Left = 2400
shp(0).Top = 2400
Do While temp < now
shp(temp + 1).Left = shp(temp).Left - 400
temp = temp + 1
Loop
temp = 0
Do While temp <= now
shp(temp).Top = shp(0).Top
temp = temp + 1
Loop
rndint = Int(Rnd * 14)
Shp1.Left = 400 * rndint
rndint = Int(Rnd * 14)
Shp1.Top = 400 * rndint

End Sub

Private Sub Timer1_Timer()
If goside = 3 Then
    temp = now
    Do While temp > 0
        shp(temp).Left = shp(temp - 1).Left
        temp = temp - 1
    Loop
    shp(0).Left = shp(0).Left + 400
    temp = now
    Do While temp > 0
    shp(temp).Top = shp(temp - 1).Top
    temp = temp - 1
    Loop
ElseIf goside = 0 Then
    temp = now
    Do While temp > 0
    shp(temp).Top = shp(temp - 1).Top
    temp = temp - 1
    Loop
    shp(0).Top = shp(0).Top - 400
    temp = now
    Do While temp > 0
        shp(temp).Left = shp(temp - 1).Left
        temp = temp - 1
    Loop
ElseIf goside = 1 Then
    temp = now
    Do While temp > 0
        shp(temp).Left = shp(temp - 1).Left
        temp = temp - 1
    Loop
    shp(0).Left = shp(0).Left - 400
    temp = now
    Do While temp > 0
    shp(temp).Top = shp(temp - 1).Top
    temp = temp - 1
    Loop
ElseIf goside = 2 Then
    temp = now
    Do While temp > 0
    shp(temp).Top = shp(temp - 1).Top
    temp = temp - 1
    Loop
    shp(0).Top = shp(0).Top + 400
    temp = now
    Do While temp > 0
        shp(temp).Left = shp(temp - 1).Left
        temp = temp - 1
    Loop
End If
temp = 1
Do While temp <= now
    If shp(0).Top = shp(temp).Top And shp(0).Left = shp(temp).Left Then
        MsgBox (" Game over!")
        End
    End If
    temp = temp + 1
Loop
If shp(0).Left = Shp1.Left And shp(0).Top = Shp1.Top Then
    now = now + 1
    Load shp(now)
    shp(now).Visible = True
    shp(now).Shape = 4
    rndint = Int(Rnd * 14)
    Shp1.Left = 400 * rndint
    rndint = Int(Rnd * 14)
    Shp1.Top = 400 * rndint
End If
If shp(0).Left + 350 > 6000 Or shp(0).Left < 0 Or shp(0).Top < 0 Or shp(0).Top + 700 > 6000 Then
     MsgBox (" Game over!")
     Unload Me

    End If
    temp = 0
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -