Form1.frm
资源名称:七八个vb游戏.rar [点击查看]
上传用户:tashmp
上传日期:2010-04-03
资源大小:882k
文件大小:7k
源码类别:
其他游戏
开发平台:
Visual Basic
- VERSION 5.00
- Begin VB.Form Form1
- BackColor = &H00C0C0C0&
- BorderStyle = 1 'Fixed Single
- Caption = "弹球游戏"
- ClientHeight = 4890
- ClientLeft = 45
- ClientTop = 330
- ClientWidth = 4860
- FillColor = &H008080FF&
- ForeColor = &H008080FF&
- Icon = "Form1.frx":0000
- LinkTopic = "Form1"
- MaxButton = 0 'False
- MinButton = 0 'False
- ScaleHeight = 4890
- ScaleWidth = 4860
- StartUpPosition = 3 'Windows Default
- Begin VB.Timer Timer1
- Interval = 200
- Left = 120
- Top = 3480
- End
- Begin VB.CommandButton Command2
- Caption = "退出"
- Height = 615
- Left = 1560
- TabIndex = 2
- Top = 4200
- Width = 1335
- End
- Begin VB.CommandButton Command1
- Caption = "开始"
- Default = -1 'True
- Height = 615
- Left = 240
- TabIndex = 1
- Top = 4200
- Width = 1335
- End
- Begin VB.PictureBox Picture1
- BackColor = &H80000005&
- Height = 3975
- Left = 0
- ScaleHeight = 3915
- ScaleWidth = 4755
- TabIndex = 0
- Top = 0
- Width = 4815
- Begin VB.Timer Timer2
- Interval = 1000
- Left = 4320
- Top = 3480
- End
- Begin VB.Line Line1
- BorderWidth = 5
- X1 = 1080
- X2 = 2880
- Y1 = 3720
- Y2 = 3720
- End
- Begin VB.Shape Shape1
- BackColor = &H008080FF&
- BorderColor = &H000000FF&
- FillColor = &H008080FF&
- FillStyle = 0 'Solid
- Height = 255
- Left = 3240
- Shape = 3 'Circle
- Top = 600
- Width = 255
- End
- End
- Begin VB.Label Label4
- BackColor = &H00C0FFC0&
- Caption = "0"
- BeginProperty Font
- Name = "MS Sans Serif"
- Size = 13.5
- Charset = 0
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- ForeColor = &H00000000&
- Height = 375
- Left = 3840
- TabIndex = 6
- Top = 4560
- Width = 855
- End
- Begin VB.Label Label3
- Caption = "时间 :"
- Height = 255
- Left = 3120
- TabIndex = 5
- Top = 4560
- Width = 495
- End
- Begin VB.Label Label2
- BackColor = &H00C0FFC0&
- Caption = "0"
- BeginProperty Font
- Name = "MS Sans Serif"
- Size = 13.5
- Charset = 0
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- ForeColor = &H00000000&
- Height = 375
- Left = 3840
- TabIndex = 4
- Top = 4080
- Width = 855
- End
- Begin VB.Label Label1
- Caption = "积分:"
- Height = 255
- Left = 3120
- TabIndex = 3
- Top = 4080
- Width = 735
- End
- End
- Attribute VB_Name = "Form1"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- Dim x_step As Integer
- Dim y_step As Integer
- Dim gametime As Integer
- Dim gamescore As Integer
- Dim move_x As Integer
- Private Sub Command1_Click()
- Picture1.SetFocus
- If Command1.Caption = "开始" Then
- Timer1.Enabled = True
- Timer2.Enabled = True
- Command1.Caption = "暂停"
- Exit Sub
- End If
- If Command1.Caption = "暂停" Then
- Timer1.Enabled = False
- Timer2.Enabled = False
- Command1.Caption = "开始"
- End If
- End Sub
- Private Sub Command2_Click()
- End
- End Sub
- Private Sub Form_DblClick()
- Form2.Show
- End Sub
- Private Sub Form_Load()
- x_step = 250
- y_step = 250
- 'move_x = 0
- Command1.Caption = "开始"
- Timer1.Enabled = False
- Timer2.Enabled = False
- gametime = 0
- gamescore = 0
- Form1.Left = (Screen.Width - Form1.Width) / 2
- Form1.Top = (Screen.Height - Form1.Height) / 2 - 600
- End Sub
- Private Sub Picture1_KeyDown(KeyCode As Integer, Shift As Integer)
- Select Case KeyCode
- Case 37 '如果按下左箭头,使板子向左移动
- If Line1.X1 <= Picture1.Left Then
- Line1.X1 = Picture1.Left
- Else
- Line1.X1 = Line1.X1 - (90 + move_x)
- Line1.X2 = Line1.X2 - (90 + move_x)
- End If
- Case 39 '如果按下右箭头,使板子向右移动
- If Line1.X2 >= Picture1.Left + Picture1.Width Then
- Line1.X2 = Picture1.Left + Picture1.Width
- Else
- Line1.X1 = Line1.X1 + (90 + move_x)
- Line1.X2 = Line1.X2 + (90 + move_x)
- End If
- End Select
- End Sub
- Private Sub Timer1_Timer()
- '右壁弹回
- If Shape1.Left + Shape1.Width >= Picture1.Left + Picture1.Width Then
- Shape1.Left = Picture1.Left + Picture1.Width - Shape1.Width
- x_step = -x_step
- End If
- '左壁弹回
- If Shape1.Left <= 0 Then
- Shape1.Left = 0
- x_step = -x_step
- End If
- '上壁弹回
- If Shape1.Top <= 0 Then
- Shape1.Top = 0
- y_step = -y_step
- End If
- '弹板弹回
- If Shape1.Top + Shape1.Height >= Line1.Y1 And _
- Shape1.Left >= Line1.X1 And _
- Shape1.Left <= Line1.X2 Then
- Shape1.Top = Line1.Y1 - Shape1.Height
- y_step = -y_step
- gamescore = gamescore + 10
- Label2.Caption = gamescore
- If gamescore Mod 50 = 0 Then
- If Line1.X2 - Line1.X1 > 300 Then
- Line1.X2 = Line1.X2 - 100
- If Timer1.Interval > 50 Then
- Timer1.Interval = Timer1.Interval - 30
- move_x = move_x + 15
- End If
- End If
- End If
- End If
- '使小球移动
- Shape1.Move Shape1.Left + x_step, Shape1.Top + y_step
- 'Shape1.Left = Shape1.Left + x_step
- 'Shape1.Top = Shape1.Top + y_step
- If Shape1.Top >= Line1.Y1 Then
- Timer1.Enabled = False
- Timer2.Enabled = False
- MsgBox "你输了!!!!", 64
- Call start_game
- End If
- End Sub
- Private Sub Timer2_Timer()
- gametime = gametime + 1
- Label4.Caption = Str(gametime) + "秒"
- End Sub