一 、游戏界面见上图。
二、功能
可保存、加载,游戏时可后退重新操作
合并方式2种
用键盘控制
游戏时记录时间、分数
可设置目标数(最大可选65536)
可以设置4*4到6*6方式
数字移动时显示移动效果
三、界面
1个FORM,1个Picturebox,4个ComboBox,7个label,1个ListBox,1个Timer
picturebox大小为320*320,ComboBox的DropDownStyle 选DropDownList
listbox的Visible = False(不可见)
位置参考上图,代码如下:
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class FrmMain
Inherits System.Windows.Forms.Form
'Form 重写 Dispose,以清理组件列表。
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
End Sub
'Windows 窗体设计器所必需的
Private components As System.ComponentModel.IContainer
'注意: 以下过程是 Windows 窗体设计器所必需的
'可以使用 Windows 窗体设计器修改它。
'不要使用代码编辑器修改它。
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container()
Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(FrmMain))
Me.PictureBox1 = New System.Windows.Forms.PictureBox()
Me.Label1 = New System.Windows.Forms.Label()
Me.Label2 = New System.Windows.Forms.Label()
Me.ComboBox1 = New System.Windows.Forms.ComboBox()
Me.ComboBox2 = New System.Windows.Forms.ComboBox()
Me.Label3 = New System.Windows.Forms.Label()
Me.Label4 = New System.Windows.Forms.Label()
Me.ComboBox3 = New System.Windows.Forms.ComboBox()
Me.Label5 = New System.Windows.Forms.Label()
Me.Timer1 = New System.Windows.Forms.Timer(Me.components)
Me.ListBox1 = New System.Windows.Forms.ListBox()
Me.Label6 = New System.Windows.Forms.Label()
Me.Label7 = New System.Windows.Forms.Label()
Me.ComboBox4 = New System.Windows.Forms.ComboBox()
CType(Me.PictureBox1, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'PictureBox1
'
Me.PictureBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
Me.PictureBox1.Location = New System.Drawing.Point(2, 55)
Me.PictureBox1.Name = "PictureBox1"
Me.PictureBox1.Size = New System.Drawing.Size(320, 320)
Me.PictureBox1.TabIndex = 0
Me.PictureBox1.TabStop = False
'
'Label1
'
Me.Label1.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.Label1.AutoSize = True
Me.Label1.ForeColor = System.Drawing.Color.Red
Me.Label1.Location = New System.Drawing.Point(233, 8)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(41, 12)
Me.Label1.TabIndex = 1
Me.Label1.Tag = "aaa"
Me.Label1.Text = "得分:"
'
'Label2
'
Me.Label2.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left), System.Windows.Forms.AnchorStyles)
Me.Label2.AutoSize = True
Me.Label2.ForeColor = System.Drawing.Color.Blue
Me.Label2.Location = New System.Drawing.Point(12, 383)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(299, 12)
Me.Label2.TabIndex = 2
Me.Label2.Text = "用A、S、D、W控制移动,空格键开始新游戏,ESC键暂停"
'
'ComboBox1
'
Me.ComboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
Me.ComboBox1.FormattingEnabled = True
Me.ComboBox1.Items.AddRange(New Object() {"4", "5", "6"})
Me.ComboBox1.Location = New System.Drawing.Point(4, 28)
Me.ComboBox1.Name = "ComboBox1"
Me.ComboBox1.Size = New System.Drawing.Size(38, 20)
Me.ComboBox1.TabIndex = 3
'
'ComboBox2
'
Me.ComboBox2.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
Me.ComboBox2.FormattingEnabled = True
Me.ComboBox2.Items.AddRange(New Object() {"4", "5", "6"})
Me.ComboBox2.Location = New System.Drawing.Point(48, 28)
Me.ComboBox2.Name = "ComboBox2"
Me.ComboBox2.Size = New System.Drawing.Size(38, 20)
Me.ComboBox2.TabIndex = 4
'
'Label3
'
Me.Label3.AutoSize = True
Me.Label3.Font = New System.Drawing.Font("宋体", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me.Label3.Location = New System.Drawing.Point(2, 8)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(89, 12)
Me.Label3.TabIndex = 5
Me.Label3.Text = "选择列数及行数"
'
'Label4
'
Me.Label4.AutoSize = True
Me.Label4.Font = New System.Drawing.Font("宋体", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me.Label4.Location = New System.Drawing.Point(102, 8)
Me.Label4.Name = "Label4"
Me.Label4.Size = New System.Drawing.Size(41, 12)
Me.Label4.TabIndex = 5
Me.Label4.Text = "目标数"
'
'ComboBox3
'
Me.ComboBox3.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
Me.ComboBox3.FormattingEnabled = True
Me.ComboBox3.Items.AddRange(New Object() {"256", "1024", "2048", "4096", "8192", "16384", "32768", "65536"})
Me.ComboBox3.Location = New System.Drawing.Point(98, 28)
Me.ComboBox3.Name = "ComboBox3"
Me.ComboBox3.Size = New System.Drawing.Size(60, 20)
Me.ComboBox3.TabIndex = 6
'
'Label5
'
Me.Label5.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.Label5.AutoSize = True
Me.Label5.ForeColor = System.Drawing.Color.MediumBlue
Me.Label5.Location = New System.Drawing.Point(233, 32)
Me.Label5.Name = "Label5"
Me.Label5.Size = New System.Drawing.Size(41, 12)
Me.Label5.TabIndex = 7
Me.Label5.Tag = "aaa"
Me.Label5.Text = "用时:"
'
'Timer1
'
Me.Timer1.Interval = 1000
'
'ListBox1
'
Me.ListBox1.Anchor = System.Windows.Forms.AnchorStyles.Left
Me.ListBox1.FormattingEnabled = True
Me.ListBox1.ItemHeight = 12
Me.ListBox1.Location = New System.Drawing.Point(328, 71)
Me.ListBox1.Name = "ListBox1"
Me.ListBox1.Size = New System.Drawing.Size(476, 292)
Me.ListBox1.TabIndex = 8
Me.ListBox1.Visible = False
'
'Label6
'
Me.Label6.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left), System.Windows.Forms.AnchorStyles)
Me.Label6.AutoSize = True
Me.Label6.ForeColor = System.Drawing.Color.Red
Me.Label6.Location = New System.Drawing.Point(8, 401)
Me.Label6.Name = "Label6"
Me.Label6.Size = New System.Drawing.Size(311, 12)
Me.Label6.TabIndex = 9
Me.Label6.Text = "B键退回一步(最多20步),F3键保存当前,F4键加载已保存"
'
'Label7
'
Me.Label7.AutoSize = True
Me.Label7.Font = New System.Drawing.Font("宋体", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me.Label7.Location = New System.Drawing.Point(169, 8)
Me.Label7.Name = "Label7"
Me.Label7.Size = New System.Drawing.Size(53, 12)
Me.Label7.TabIndex = 10
Me.Label7.Text = "合并方式"
'
'ComboBox4
'
Me.ComboBox4.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
Me.ComboBox4.FormattingEnabled = True
Me.ComboBox4.Items.AddRange(New Object() {"正常", "全部"})
Me.ComboBox4.Location = New System.Drawing.Point(172, 28)
Me.ComboBox4.Name = "ComboBox4"
Me.ComboBox4.Size = New System.Drawing.Size(55, 20)
Me.ComboBox4.TabIndex = 11
'
'FrmMain
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 12.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(326, 420)
Me.Controls.Add(Me.ComboBox4)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.Label7)
Me.Controls.Add(Me.Label6)
Me.Controls.Add(Me.ListBox1)
Me.Controls.Add(Me.Label5)
Me.Controls.Add(Me.ComboBox3)
Me.Controls.Add(Me.Label4)
Me.Controls.Add(Me.Label3)
Me.Controls.Add(Me.ComboBox2)
Me.Controls.Add(Me.ComboBox1)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.PictureBox1)
Me.DoubleBuffered = True
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle
Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
Me.KeyPreview = True
Me.MaximizeBox = False
Me.Name = "FrmMain"
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Me.Text = "拼数游戏"
CType(Me.PictureBox1, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
Friend WithEvents PictureBox1 As System.Windows.Forms.PictureBox
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents ComboBox1 As System.Windows.Forms.ComboBox
Friend WithEvents ComboBox2 As System.Windows.Forms.ComboBox
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents Label4 As System.Windows.Forms.Label
Friend WithEvents ComboBox3 As System.Windows.Forms.ComboBox
Friend WithEvents Label5 As System.Windows.Forms.Label
Friend WithEvents Timer1 As System.Windows.Forms.Timer
Friend WithEvents ListBox1 As System.Windows.Forms.ListBox
Friend WithEvents Label6 As System.Windows.Forms.Label
Friend WithEvents Label7 As System.Windows.Forms.Label
Friend WithEvents ComboBox4 As System.Windows.Forms.ComboBox
End Class