目 錄
一、 畢業(yè)設(shè)計內(nèi)容 3
二、 畢業(yè)設(shè)計目的 3
三、 工具/準(zhǔn)備工作 3
四、 設(shè)計步驟和方法 3
(一) 總體設(shè)計 3
1. 總體設(shè)計思路及設(shè)計圖 3
2. 界面設(shè)計 4
3. 全局變量設(shè)計 4
(二) 詳細(xì)設(shè)計 5
1. 刷新棋盤 5
2. 繪制棋盤 5
3. 分步計時 5
4. 顯示光標(biāo) 6
5. 判斷勝負(fù) 8
6. 判斷禁手 10
7. 電腦落子 15
8. 玩家落子 18
9. 開始游戲 19
10. 退出游戲 20
11. 重新開局 20
12. 玩家認(rèn)輸 21
13. 玩家悔棋 22
(三) 測試 23
1. 判斷勝負(fù)模塊測試 23
2. 判斷禁手模塊測試 23
五、 心得體會 24
一、畢業(yè)設(shè)計內(nèi)容
在Visual Studio 2015 平臺上,開發(fā)一個“五子棋游戲”的Windows Form應(yīng)用程序,題目要求:
1.整體規(guī)劃,即畫出棋盤和顯示出“游戲開始”、“悔棋”、“退出游戲”等按鈕。
2.游戲界面的具體實現(xiàn),即有絕對坐標(biāo)與相對坐標(biāo)、又有界面的顏色與大小和各部分所處的位置。
3.在鼠標(biāo)在棋盤上經(jīng)過的時候,可以看出光標(biāo)在那里;
4.正常落棋子,不會覆蓋已有棋子。
5.記錄游戲中棋子的落子過程,并且允許悔棋
6.判斷雙方輸贏,先走出五子連珠的一方贏
7.先下者落子時不允許走禁手。
二、畢業(yè)設(shè)計目的
綜合運用c#.net知識,在vs 2015 平臺上,進行控制臺應(yīng)用程序和簡單Windows Form應(yīng)用程序的開發(fā);本文轉(zhuǎn)載自http://www.biyezuopin.vip/onews.asp?id=15126初步熟悉開發(fā)一個Windows軟件的流程。
三、工具/準(zhǔn)備工作
Microsoft Visual Studio 2015,PC機一臺,上網(wǎng)查找資料,相關(guān)參考書籍。
四、設(shè)計步驟和方法
(一)總體設(shè)計
1.總體設(shè)計思路及設(shè)計圖
(1)設(shè)計思路
① 充分了解五子棋游戲的一般規(guī)則,了解三三禁手、四四禁手和長連禁手的判定條件,以及黑白方如何落子、如何計時;
② 結(jié)合游戲規(guī)則設(shè)計簡潔美觀的游戲界面,使用相關(guān)控件,注意控件之間的聯(lián)系;
③ 搜集資料,了解控件有關(guān)的函數(shù)及使用方法,完善程序邏輯;
④ 根據(jù)擬定好的程序邏輯,定義相關(guān)的全局變量和自定義函數(shù);
⑤ 模擬多種情況調(diào)試程序,找出隱藏的錯誤,完善程序;
⑥ 整合邏輯及相關(guān)程序,完成畢業(yè)設(shè)計報告。文章來源:http://www.zghlxwxcb.cn/news/detail-440151.html
namespace Game4873
{
partial class Form1
{
/// <summary>
/// 必需的設(shè)計器變量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的資源。
/// </summary>
/// <param name="disposing">如果應(yīng)釋放托管資源,為 true;否則為 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows 窗體設(shè)計器生成的代碼
/// <summary>
/// 設(shè)計器支持所需的方法 - 不要修改
/// 使用代碼編輯器修改此方法的內(nèi)容。
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.radioButton2 = new System.Windows.Forms.RadioButton();
this.radioButton1 = new System.Windows.Forms.RadioButton();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.button5 = new System.Windows.Forms.Button();
this.button4 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.button3 = new System.Windows.Forms.Button();
this.button1 = new System.Windows.Forms.Button();
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.panel1 = new System.Windows.Forms.Panel();
this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.textBox2 = new System.Windows.Forms.TextBox();
this.textBox1 = new System.Windows.Forms.TextBox();
this.panel2 = new System.Windows.Forms.Panel();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
this.splitContainer1.SuspendLayout();
this.panel1.SuspendLayout();
this.SuspendLayout();
//
// groupBox1
//
this.groupBox1.Controls.Add(this.radioButton2);
this.groupBox1.Controls.Add(this.radioButton1);
this.groupBox1.Font = new System.Drawing.Font("楷體", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.groupBox1.ForeColor = System.Drawing.SystemColors.ControlText;
this.groupBox1.Location = new System.Drawing.Point(30, 14);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(105, 132);
this.groupBox1.TabIndex = 0;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "下棋順序";
//
// radioButton2
//
this.radioButton2.AutoSize = true;
this.radioButton2.Font = new System.Drawing.Font("楷體", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.radioButton2.ForeColor = System.Drawing.SystemColors.ControlText;
this.radioButton2.Location = new System.Drawing.Point(6, 82);
this.radioButton2.Name = "radioButton2";
this.radioButton2.Size = new System.Drawing.Size(90, 20);
this.radioButton2.TabIndex = 1;
this.radioButton2.Text = "電腦先手";
this.radioButton2.UseVisualStyleBackColor = true;
//
// radioButton1
//
this.radioButton1.AutoSize = true;
this.radioButton1.Checked = true;
this.radioButton1.Font = new System.Drawing.Font("楷體", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.radioButton1.ForeColor = System.Drawing.SystemColors.ControlText;
this.radioButton1.Location = new System.Drawing.Point(7, 44);
this.radioButton1.Name = "radioButton1";
this.radioButton1.Size = new System.Drawing.Size(90, 20);
this.radioButton1.TabIndex = 0;
this.radioButton1.TabStop = true;
this.radioButton1.Text = "玩家先手";
this.radioButton1.UseVisualStyleBackColor = true;
//
// groupBox2
//
this.groupBox2.Controls.Add(this.button5);
this.groupBox2.Controls.Add(this.button4);
this.groupBox2.Controls.Add(this.button2);
this.groupBox2.Controls.Add(this.button3);
this.groupBox2.Controls.Add(this.button1);
this.groupBox2.Font = new System.Drawing.Font("楷體", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.groupBox2.ForeColor = System.Drawing.SystemColors.ControlText;
this.groupBox2.Location = new System.Drawing.Point(162, 14);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(293, 132);
this.groupBox2.TabIndex = 1;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "游戲開關(guān)";
//
// button5
//
this.button5.BackColor = System.Drawing.SystemColors.ActiveCaption;
this.button5.Enabled = false;
this.button5.ForeColor = System.Drawing.SystemColors.ControlText;
this.button5.Location = new System.Drawing.Point(115, 82);
this.button5.Name = "button5";
this.button5.Size = new System.Drawing.Size(65, 28);
this.button5.TabIndex = 4;
this.button5.Text = "悔棋";
this.button5.UseVisualStyleBackColor = false;
this.button5.Click += new System.EventHandler(this.button5_Click);
//
// button4
//
this.button4.BackColor = System.Drawing.SystemColors.ActiveCaption;
this.button4.Enabled = false;
this.button4.ForeColor = System.Drawing.SystemColors.ControlText;
this.button4.Location = new System.Drawing.Point(202, 82);
this.button4.Name = "button4";
this.button4.Size = new System.Drawing.Size(65, 28);
this.button4.TabIndex = 3;
this.button4.Text = "認(rèn)輸";
this.button4.UseVisualStyleBackColor = false;
this.button4.Click += new System.EventHandler(this.button4_Click);
//
// button2
//
this.button2.BackColor = System.Drawing.SystemColors.ActiveCaption;
this.button2.ForeColor = System.Drawing.SystemColors.ControlText;
this.button2.Location = new System.Drawing.Point(169, 39);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(65, 28);
this.button2.TabIndex = 2;
this.button2.Text = "退出";
this.button2.UseVisualStyleBackColor = false;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// button3
//
this.button3.BackColor = System.Drawing.SystemColors.ActiveCaption;
this.button3.Enabled = false;
this.button3.ForeColor = System.Drawing.SystemColors.ControlText;
this.button3.Location = new System.Drawing.Point(30, 82);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(65, 28);
this.button3.TabIndex = 1;
this.button3.Text = "重開";
this.button3.UseVisualStyleBackColor = false;
this.button3.Click += new System.EventHandler(this.button3_Click);
//
// button1
//
this.button1.BackColor = System.Drawing.SystemColors.ActiveCaption;
this.button1.ForeColor = System.Drawing.SystemColors.ControlText;
this.button1.Location = new System.Drawing.Point(62, 39);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(65, 28);
this.button1.TabIndex = 0;
this.button1.Text = "開始";
this.button1.UseVisualStyleBackColor = false;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// splitContainer1
//
this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitContainer1.IsSplitterFixed = true;
this.splitContainer1.Location = new System.Drawing.Point(0, 0);
this.splitContainer1.Name = "splitContainer1";
this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal;
//
// splitContainer1.Panel1
//
this.splitContainer1.Panel1.Controls.Add(this.panel1);
//
// splitContainer1.Panel2
//
this.splitContainer1.Panel2.Controls.Add(this.panel2);
this.splitContainer1.Size = new System.Drawing.Size(484, 687);
this.splitContainer1.SplitterDistance = 191;
this.splitContainer1.TabIndex = 3;
//
// panel1
//
this.panel1.Controls.Add(this.label2);
this.panel1.Controls.Add(this.label1);
this.panel1.Controls.Add(this.groupBox1);
this.panel1.Controls.Add(this.textBox2);
this.panel1.Controls.Add(this.groupBox2);
this.panel1.Controls.Add(this.textBox1);
this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(484, 191);
this.panel1.TabIndex = 0;
this.panel1.TabStop = true;
//
// label2
//
this.label2.AutoSize = true;
this.label2.BackColor = System.Drawing.Color.Transparent;
this.label2.Font = new System.Drawing.Font("宋體", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label2.Location = new System.Drawing.Point(249, 158);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(130, 24);
this.label2.TabIndex = 4;
this.label2.Text = "白方計時:";
//
// label1
//
this.label1.AutoSize = true;
this.label1.BackColor = System.Drawing.Color.Transparent;
this.label1.Font = new System.Drawing.Font("宋體", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label1.Location = new System.Drawing.Point(26, 158);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(130, 24);
this.label1.TabIndex = 3;
this.label1.Text = "黑方計時:";
//
// textBox2
//
this.textBox2.BackColor = System.Drawing.SystemColors.Control;
this.textBox2.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.textBox2.Font = new System.Drawing.Font("黑體", 18F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.textBox2.ForeColor = System.Drawing.Color.Red;
this.textBox2.Location = new System.Drawing.Point(385, 158);
this.textBox2.Name = "textBox2";
this.textBox2.ReadOnly = true;
this.textBox2.Size = new System.Drawing.Size(54, 28);
this.textBox2.TabIndex = 2;
this.textBox2.Text = "00";
this.textBox2.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// textBox1
//
this.textBox1.BackColor = System.Drawing.SystemColors.Control;
this.textBox1.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.textBox1.Font = new System.Drawing.Font("黑體", 18F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.textBox1.ForeColor = System.Drawing.Color.Red;
this.textBox1.Location = new System.Drawing.Point(162, 158);
this.textBox1.Name = "textBox1";
this.textBox1.ReadOnly = true;
this.textBox1.Size = new System.Drawing.Size(54, 28);
this.textBox1.TabIndex = 0;
this.textBox1.Text = "00";
this.textBox1.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// panel2
//
this.panel2.BackColor = System.Drawing.SystemColors.ActiveCaption;
this.panel2.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel2.Location = new System.Drawing.Point(0, 0);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(484, 492);
this.panel2.TabIndex = 0;
this.panel2.Paint += new System.Windows.Forms.PaintEventHandler(this.panel2_Paint);
this.panel2.MouseClick += new System.Windows.Forms.MouseEventHandler(this.panel2_MouseClick);
this.panel2.MouseMove += new System.Windows.Forms.MouseEventHandler(this.panel2_MouseMove);
//
// timer1
//
this.timer1.Interval = 1000;
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.SystemColors.Control;
this.ClientSize = new System.Drawing.Size(484, 687);
this.Controls.Add(this.splitContainer1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "Form1";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "五子棋游戲";
this.TopMost = true;
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.groupBox2.ResumeLayout(false);
this.splitContainer1.Panel1.ResumeLayout(false);
this.splitContainer1.Panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
this.splitContainer1.ResumeLayout(false);
this.panel1.ResumeLayout(false);
this.panel1.PerformLayout();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.RadioButton radioButton2;
private System.Windows.Forms.RadioButton radioButton1;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.Button button4;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Button button3;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.SplitContainer splitContainer1;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Panel panel2;
private System.Windows.Forms.Button button5;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Timer timer1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label1;
}
}
文章來源地址http://www.zghlxwxcb.cn/news/detail-440151.html
到了這里,關(guān)于基于C#的五子棋游戲設(shè)計的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!