Form1.frm
资源名称:七八个vb游戏.rar [点击查看]
上传用户:tashmp
上传日期:2010-04-03
资源大小:882k
文件大小:12k
源码类别:
其他游戏
开发平台:
Visual Basic
- VERSION 5.00
- Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
- Begin VB.Form Form1
- BorderStyle = 1 'Fixed Single
- Caption = "贪吃蛇"
- ClientHeight = 6255
- ClientLeft = 150
- ClientTop = 720
- ClientWidth = 5190
- FillColor = &H00FFFFFF&
- Icon = "Form1.frx":0000
- KeyPreview = -1 'True
- LinkTopic = "Form1"
- MaxButton = 0 'False
- MinButton = 0 'False
- Picture = "Form1.frx":030A
- ScaleHeight = 6255
- ScaleWidth = 5190
- StartUpPosition = 3 'Windows Default
- Begin MSComctlLib.Toolbar Toolbar1
- Align = 1 'Align Top
- Height = 870
- Left = 0
- TabIndex = 1
- Top = 0
- Width = 5190
- _ExtentX = 9155
- _ExtentY = 1535
- ButtonWidth = 1349
- ButtonHeight = 1376
- Appearance = 1
- ImageList = "ImageList1"
- DisabledImageList= "ImageList1"
- _Version = 393216
- BeginProperty Buttons {66833FE8-8583-11D1-B16A-00C0F0283628}
- NumButtons = 6
- BeginProperty Button1 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Key = "start"
- Object.ToolTipText = "开始游戏"
- ImageIndex = 1
- EndProperty
- BeginProperty Button2 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Key = "stop"
- Object.ToolTipText = "暂停游戏"
- ImageIndex = 2
- EndProperty
- BeginProperty Button3 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Key = "gogo"
- Object.ToolTipText = "解除暂停"
- ImageIndex = 4
- EndProperty
- BeginProperty Button4 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Key = "mm"
- Object.ToolTipText = "背景选择"
- ImageIndex = 3
- EndProperty
- BeginProperty Button5 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Key = "nd"
- Object.ToolTipText = "难度选择"
- ImageIndex = 5
- Style = 5
- BeginProperty ButtonMenus {66833FEC-8583-11D1-B16A-00C0F0283628}
- NumButtonMenus = 3
- BeginProperty ButtonMenu1 {66833FEE-8583-11D1-B16A-00C0F0283628}
- Key = "man"
- Text = "较慢"
- EndProperty
- BeginProperty ButtonMenu2 {66833FEE-8583-11D1-B16A-00C0F0283628}
- Key = "common"
- Text = "中等"
- EndProperty
- BeginProperty ButtonMenu3 {66833FEE-8583-11D1-B16A-00C0F0283628}
- Key = "kuai"
- Text = "较快"
- EndProperty
- EndProperty
- EndProperty
- BeginProperty Button6 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Key = "overgame"
- Object.ToolTipText = "退出游戏"
- ImageIndex = 6
- EndProperty
- EndProperty
- End
- Begin MSComctlLib.ImageList ImageList1
- Left = 4560
- Top = 2880
- _ExtentX = 1005
- _ExtentY = 1005
- BackColor = 12632256
- ImageWidth = 44
- ImageHeight = 46
- MaskColor = 12632256
- _Version = 393216
- BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628}
- NumListImages = 6
- BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "Form1.frx":A2F5
- Key = ""
- EndProperty
- BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "Form1.frx":BC77
- Key = ""
- EndProperty
- BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "Form1.frx":C569
- Key = ""
- EndProperty
- BeginProperty ListImage4 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "Form1.frx":DEEB
- Key = ""
- EndProperty
- BeginProperty ListImage5 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "Form1.frx":E792
- Key = ""
- EndProperty
- BeginProperty ListImage6 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "Form1.frx":F073
- Key = ""
- EndProperty
- EndProperty
- End
- Begin VB.Timer Timer3
- Interval = 700
- Left = 4680
- Top = 2280
- End
- Begin VB.Timer Timer2
- Interval = 5000
- Left = 4680
- Top = 1320
- End
- Begin VB.Timer Timer1
- Interval = 200
- Left = 4680
- Top = 1800
- End
- Begin VB.Label Labelscore
- BackColor = &H80000008&
- Caption = "0"
- BeginProperty Font
- Name = "MS Sans Serif"
- Size = 9.75
- Charset = 0
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- ForeColor = &H80000009&
- Height = 375
- Left = 4680
- TabIndex = 0
- Top = 960
- Width = 495
- End
- Begin VB.Shape Shape2
- BorderColor = &H80000003&
- FillColor = &H0080FF80&
- FillStyle = 0 'Solid
- Height = 135
- Left = 480
- Shape = 3 'Circle
- Top = 2520
- Width = 135
- End
- Begin VB.Shape Shape1
- BorderColor = &H80000001&
- FillColor = &H00FF80FF&
- FillStyle = 0 'Solid
- Height = 255
- Index = 3
- Left = 4080
- Top = 4200
- Width = 255
- End
- Begin VB.Shape Shape1
- BorderColor = &H80000001&
- FillColor = &H00C0C0FF&
- FillStyle = 0 'Solid
- Height = 255
- Index = 2
- Left = 3840
- Top = 4200
- Width = 255
- End
- Begin VB.Shape Shape1
- BorderColor = &H80000004&
- FillColor = &H0080FF80&
- FillStyle = 0 'Solid
- Height = 255
- Index = 1
- Left = 3600
- Top = 4200
- Width = 255
- End
- Begin VB.Shape Shape1
- BorderColor = &H80000001&
- FillColor = &H00FF8080&
- FillStyle = 0 'Solid
- Height = 255
- Index = 0
- Left = 3360
- Shape = 2 'Oval
- Top = 4200
- Width = 255
- End
- Begin VB.Line Line4
- BorderColor = &H80000001&
- X1 = 0
- X2 = 0
- Y1 = 960
- Y2 = 6240
- End
- Begin VB.Line Line3
- BorderColor = &H80000001&
- X1 = 5160
- X2 = 0
- Y1 = 6240
- Y2 = 6240
- End
- Begin VB.Line Line2
- BorderColor = &H80000001&
- X1 = 5160
- X2 = 5160
- Y1 = 960
- Y2 = 6240
- End
- Begin VB.Line Line1
- BorderColor = &H80000001&
- X1 = 0
- X2 = 5160
- Y1 = 960
- Y2 = 960
- End
- Begin VB.Menu game
- Caption = "游戏"
- Begin VB.Menu start
- Caption = "开始"
- End
- End
- End
- Attribute VB_Name = "Form1"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
- 'Runawy =0 左移
- ' =1 上移
- ' =2 右
- ' =3 下
- Select Case KeyCode
- Case 37 '点击左键
- If Runway <> 2 Then '蛇没有向右移动
- Runway = 0 '左
- End If
- Case 38 '点击上键
- If Runway <> 3 Then
- Runway = 1
- End If
- Case 39 '点击右键
- If Runway <> 0 Then
- Runway = 2
- End If
- Case 40 '点击下键
- If Runway <> 1 Then
- Runway = 3
- End If
- Case 83 '点击s键为暂停
- 'MsgBox "s键"
- Call stop_game
- Case 84 '再次开始游戏
- Call start_game
- End Select
- End Sub
- Private Sub Form_Load()
- Timer1.Enabled = False
- Timer2.Enabled = False
- 'Shape2.Visible = False
- Timer3.Enabled = False
- Form1.picture = LoadPicture("")
- p = 0
- p1 = 0
- Runway = 0
- Runstep = Shape1(0).Width
- maxlong = 3 '记录蛇身的长度
- m_game = 1 '第一关
- score = 0 '记录分数
- 'Line5.Visible = False
- Labelscore.ForeColor = RGB(0, 255, 0)
- time1 = Timer1.Interval
- Dim i As Integer
- For i = 0 To 3 Step 1 '游戏开始前 记录蛇的位置
- snake_init(i).x = Shape1(i).Left
- snake_init(i).y = Shape1(i).Top
- '
- 'snake_stop(i).x = Shape1(i).Left
- 'snake_stop(i).y = Shape1(i).Top
- Next i
- End Sub
- '开始游戏
- Private Sub start_Click()
- Timer1.Enabled = True
- Timer2.Enabled = True
- Call init_game
- End Sub
- Private Sub stop_Click()
- End Sub
- '
- Private Sub Timer1_Timer()
- '在蛇移动前 记录蛇头的位置
- snake_point.x = Shape1(0).Left
- snake_point.y = Shape1(0).Top
- 'snake_stopX(0) = Shape1(0).Left
- 'snake_stopY(0) = Shape1(0).Top
- Select Case Runway
- Case 0 '左移动
- Shape1(0).Left = Shape1(0).Left - Runstep
- Call move_snake '移动蛇
- Call vore_game '判断游戏是否结束
- Call group_snake '记录蛇的增长
- Case 1 '上移动
- Shape1(0).Top = Shape1(0).Top - Runstep
- Call move_snake '移动蛇
- Call vore_game '判断游戏是否结束
- Call group_snake '记录蛇的增长
- Case 2 ' 右移动
- Shape1(0).Left = Shape1(0).Left + Runstep
- Call move_snake '移动蛇
- Call vore_game '判断游戏是否结束
- Call group_snake '记录蛇的增长
- Case 3
- Shape1(0).Top = Shape1(0).Top + Runstep
- Call move_snake '移动蛇
- Call vore_game '判断游戏是否结束
- Call group_snake '记录蛇的增长
- End Select
- End Sub
- '生成食物
- Private Sub Timer2_Timer()
- Dim pointx As Integer
- Dim pointy As Integer
- Randomize
- pointx = Rnd * (Line1.X2 - Line1.X1 + 5) + Line1.X1
- pointy = Rnd * (Line2.Y2 - Line2.Y1 + 5) + Line2.Y1
- Shape2.Left = pointx
- Shape2.Top = pointy
- Shape2.FillColor = RGB(Rnd * 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
- Shape1(i).Visible = False
- Next i
- Else
- For i = 0 To maxlong Step 1
- Shape1(i).Visible = True
- Next i
- End If
- If p1 = 6 Then
- Timer3.Enabled = False
- 'MsgBox "结束游戏!!"
- End If
- Screen.MousePointer = vbArrow
- End Sub
- Private Sub Toolbar1_ButtonClick(ByVal 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
- Form1.picture = LoadPicture("")
- Exit Sub
- End If
- Dim s1 As String
- s1 = "bj" & picture & ".jpg"
- Form1.picture = LoadPicture(App.Path + s1)
- End Select
- End Sub