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

📄 form1.frm

📁 常见的小游戏
💻 FRM
📖 第 1 页 / 共 2 页
字号:
VERSION 5.00
Object = "{C1A8AF28-1257-101B-8FB0-0020AF039CA3}#1.1#0"; "MCI32.OCX"
Begin VB.Form Form1 
   AutoRedraw      =   -1  'True
   BorderStyle     =   1  'Fixed Single
   Caption         =   "打砖块"
   ClientHeight    =   6345
   ClientLeft      =   3390
   ClientTop       =   2010
   ClientWidth     =   8550
   FillColor       =   &H00C0C0C0&
   FillStyle       =   0  'Solid
   Icon            =   "Form1.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   Picture         =   "Form1.frx":08CA
   ScaleHeight     =   423
   ScaleMode       =   3  'Pixel
   ScaleWidth      =   570
   Begin VB.Timer Timer2 
      Interval        =   500
      Left            =   7800
      Top             =   4800
   End
   Begin VB.PictureBox king 
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      ForeColor       =   &H80000008&
      Height          =   900
      Left            =   3645
      ScaleHeight     =   58
      ScaleMode       =   3  'Pixel
      ScaleWidth      =   68
      TabIndex        =   5
      Top             =   360
      Visible         =   0   'False
      Width           =   1050
   End
   Begin VB.Timer Timer1 
      Interval        =   100
      Left            =   7800
      Top             =   3360
   End
   Begin VB.PictureBox prize 
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      ForeColor       =   &H80000008&
      Height          =   375
      Left            =   3600
      Picture         =   "Form1.frx":4FF9
      ScaleHeight     =   23
      ScaleMode       =   3  'Pixel
      ScaleWidth      =   23
      TabIndex        =   4
      Top             =   2520
      Visible         =   0   'False
      Width           =   375
   End
   Begin MCI.MMControl MMControl1 
      Height          =   615
      Left            =   2400
      TabIndex        =   3
      Top             =   4440
      Visible         =   0   'False
      Width           =   3540
      _ExtentX        =   6244
      _ExtentY        =   1085
      _Version        =   393216
      DeviceType      =   ""
      FileName        =   ""
   End
   Begin VB.Timer Timermove 
      Enabled         =   0   'False
      Interval        =   30
      Left            =   7800
      Top             =   4200
   End
   Begin VB.Label Label2 
      BackStyle       =   0  'Transparent
      Caption         =   "<Z>=快速  <X>=中速  <C>=慢速"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00FFFFFF&
      Height          =   255
      Left            =   2640
      TabIndex        =   6
      Top             =   6000
      Width           =   2655
   End
   Begin VB.Image Image1 
      Height          =   300
      Index           =   1
      Left            =   600
      Picture         =   "Form1.frx":5923
      Top             =   0
      Visible         =   0   'False
      Width           =   525
   End
   Begin VB.Image Image1 
      Height          =   300
      Index           =   0
      Left            =   120
      Picture         =   "Form1.frx":613D
      Top             =   0
      Visible         =   0   'False
      Width           =   525
   End
   Begin VB.Image king4 
      Height          =   900
      Left            =   840
      Picture         =   "Form1.frx":697B
      Top             =   0
      Visible         =   0   'False
      Width           =   1050
   End
   Begin VB.Image king3 
      Height          =   900
      Left            =   480
      Picture         =   "Form1.frx":7B45
      Top             =   0
      Visible         =   0   'False
      Width           =   1050
   End
   Begin VB.Image king2 
      Height          =   900
      Left            =   240
      Picture         =   "Form1.frx":8D15
      Top             =   0
      Visible         =   0   'False
      Width           =   1050
   End
   Begin VB.Image king1 
      Height          =   900
      Left            =   0
      Picture         =   "Form1.frx":A0A1
      Top             =   0
      Visible         =   0   'False
      Width           =   1050
   End
   Begin VB.Label Label1 
      BackStyle       =   0  'Transparent
      Caption         =   "剩余小球:"
      ForeColor       =   &H00FFFFFF&
      Height          =   255
      Left            =   6720
      TabIndex        =   2
      Top             =   6075
      Width           =   975
   End
   Begin VB.Shape remained 
      FillColor       =   &H00FFFFFF&
      FillStyle       =   0  'Solid
      Height          =   180
      Index           =   1
      Left            =   8160
      Shape           =   3  'Circle
      Top             =   6075
      Width           =   180
   End
   Begin VB.Shape remained 
      FillColor       =   &H00FFFFFF&
      FillStyle       =   0  'Solid
      Height          =   180
      Index           =   0
      Left            =   7680
      Shape           =   3  'Circle
      Top             =   6075
      Width           =   180
   End
   Begin VB.Label startword 
      BackStyle       =   0  'Transparent
      Caption         =   "按空格键开始"
      ForeColor       =   &H00FFFFFF&
      Height          =   255
      Left            =   720
      TabIndex        =   1
      Top             =   6000
      Width           =   1215
   End
   Begin VB.Shape ball 
      FillColor       =   &H00E0E0E0&
      FillStyle       =   0  'Solid
      Height          =   180
      Left            =   3480
      Shape           =   3  'Circle
      Top             =   5640
      Width           =   180
   End
   Begin VB.Shape board1 
      BorderStyle     =   0  'Transparent
      FillColor       =   &H00C0C0C0&
      FillStyle       =   0  'Solid
      Height          =   135
      Left            =   3480
      Top             =   5880
      Width           =   1215
   End
   Begin VB.Shape board 
      BackStyle       =   1  'Opaque
      BorderStyle     =   0  'Transparent
      FillColor       =   &H0000C000&
      FillStyle       =   0  'Solid
      Height          =   120
      Left            =   3000
      Top             =   5760
      Width           =   1200
   End
   Begin VB.Image brick 
      Height          =   300
      Left            =   7680
      Picture         =   "Form1.frx":B28E
      Top             =   1680
      Visible         =   0   'False
      Width           =   525
   End
   Begin VB.Label lblscore 
      BackStyle       =   0  'Transparent
      Caption         =   "0"
      BeginProperty Font 
         Name            =   "Basemic Times"
         Size            =   12
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00808000&
      Height          =   375
      Left            =   6720
      TabIndex        =   0
      Top             =   480
      Width           =   615
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Const marginleft = 74
Const marginright = 494
Const margintop = 96
Const marginbottom = 216
Const brickheight = 20
Const brickwidth = 35
Const row = 12 '砖墙的横向砖头数
Const liner = 6 '砖墙的纵向砖头数
Dim presentrow As Integer: Dim presentline As Integer '记录当前绘制砖头的位置
Dim tostart As Boolean
Dim score As Integer: Dim multiplier As Integer '定义记录得分和得分翻倍之倍数的变量
Dim presentscore As Long '打碎当前砖块的得分
Dim caculation As Integer '计算打碎一块砖应得分数的专用变量
Dim life As Integer '记录所剩生命数
Dim prizeused As Boolean
Const radius = 6 '小球半径
Const step = 5 '小球移动步长
Dim counting As Integer '记录剩余砖数量
Dim vecX As Integer: Dim vecY As Integer '小球移动的横、纵坐标向量
Dim hit(12, 6) As Boolean '计算哪些是打过的,供counting作统计
Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long
Dim ballright As Long: Dim ballleft As Long: Dim balltop As Long: Dim ballbottom As Long '捕捉小球的上下左右四个顶点位置

Private Sub Form_Activate()
For presentrow = 0 To row - 1 '以循环嵌套绘制砖墙
  For presentline = 0 To liner - 1
    Randomize
    Form1.PaintPicture brick.Picture, marginleft + presentrow * brickwidth, margintop + presentline * brickheight
  Next presentline
Next presentrow
board1.Width = board.Width: board1.Top = board.Top: board1.Left = board.Left: board1.Height = board.Height / 2
tostart = False
Me.SetFocus
End Sub

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer) '根据键盘按键移动挡板
If KeyCode = vbKeySpace And startword.Visible = True Then
  tostart = True
  startword.Visible = False: score = 0: lblscore.Caption = "0"
  For presentrow = 0 To row - 1 '以循环嵌套绘制砖墙
    For presentline = 0 To liner - 1
      Form1.PaintPicture Image1(Int(Rnd() * 2)).Picture, marginleft + presentrow * brickwidth, margintop + presentline * brickheight
      hit(presentrow, presentline) = False
    Next presentline
  Next presentrow
  counting = 72: prizeused = False
  board.Width = 80: board1.Width = 80
  project
  Timermove.Enabled = True: Timer1.Enabled = False
  remained(0).FillColor = vbWhite: remained(1).FillColor = vbWhite: life = 3
End If
If KeyCode = vbKeyRight And tostart = True Then
  If board.Left + board.Width + 40 > Me.ScaleWidth Then
    board.Left = Me.ScaleWidth - board.Width
  Else
    board.Left = board.Left + 40
  End If
  board1.Left = board.Left
End If
If KeyCode = vbKeyLeft And tostart = True Then
  If board.Left < 40 Then
    board.Left = 0
  Else
    board.Left = board.Left - 40
  End If
  board1.Left = board.Left
End If
Select Case KeyCode
Case vbKeyZ
  Timermove.Interval = 20
Case vbKeyX
  Timermove.Interval = 25

⌨️ 快捷键说明

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