資源簡介
能夠?qū)崿F(xiàn)類似于Windows掃雷的基本功能。可視化程序設(shè)計(jì)課程設(shè)計(jì)

代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Linq;
using?System.Text;
using?System.Windows.Forms;
using?System.IO;
namespace?掃雷_xxb
{
????public?partial?class?Form1?:?Form
????{
????????public?Form1()
????????{
????????????InitializeComponent();
????????}
????????private?Button[]?Mines;???//定義一個(gè)?二維動(dòng)態(tài)數(shù)組?用于顯示雷區(qū)
????????private?int?XNum?=?9;???//初始化累的列數(shù)(即為:初級時(shí)的行列數(shù))
????????private?int?YNum?=?9;???//初始化雷的行數(shù)
????????public?static?int?zdyXNum;???//用于自定義中的列數(shù)
????????public?static?int?zdyYNum;???//用于自定義中的行數(shù)
????????private?int?MineNum?=?10;???//初始化雷的總數(shù)
????????public?static?int?zdyMineNum;???//用于記錄自定義中的雷數(shù)
????????private?int[]?Turn;???//用二維數(shù)組賦值:-1?表示這個(gè)位置已經(jīng)翻開;0?表示這個(gè)位置沒有翻開;1?表示這個(gè)位置插上紅旗;
????????public?static?int?CostTime?=?0;???//計(jì)量所用的時(shí)間
????????private?int?StartTime?=?0;???//初始化時(shí)間
????????private?int?RestMine?=?10;???//用于改變等級時(shí)載入剩余雷數(shù)
????????private?int?MineWidth?=?20;???//?控制雷塊的大小
????????private?void?button1_Click(object?sender?EventArgs?e)???//這是一個(gè)開始按鈕,單擊即開始游戲
????????{
????????????button1.Image?=?Image.FromFile(“face.bmp“);???//用于控制開始按鈕的圖標(biāo),開始時(shí)位笑臉
????????????DelAllMines();???//刪除所有的雷區(qū)控件(很重要,用于不讓其改變等級時(shí)有參與)
????????????RestMine?=?MineNum;???//用于記錄雷數(shù),開始時(shí)剩余雷數(shù)為總雷數(shù)
????????????CostTime?=?0;???//用于記錄從開始到現(xiàn)在游戲用時(shí),開始為0
????????????label1.Text?=?CostTime.ToString();???//label1窗體中用于顯示所用的時(shí)間
????????????GamesBegin();???//開始游戲
????????????GameInit();???//游戲初始化
????????????timer1.Enabled?=?true;???//觸發(fā)計(jì)時(shí)器
????????}
????????private?void?DelAllMines()???//刪除所有的雷區(qū)
????????{
????????????for?(int?i?=?0;?i?????????????????for?(int?j?=?0;?j?????????????????{
????????????????????Button?n?=?new?Button();???//定義一個(gè)新的button
????????????????????n?=?(Button)Mines[ij];???//強(qiáng)制類型轉(zhuǎn)換
????????????????????this.Controls.Remove(Mines[i?j]);???//刪除所指雷區(qū)
????????????????}
????????}
????????private?void?GamesBegin()???//用于開始游戲,主要是定義雷區(qū)
????????{
????????????Turn?=?new?int[XNum?YNum];???//定義新的二維數(shù)組
????????????Mines?=?new?Button[XNum?YNum];???//定義按鈕
????????????for?(int?x?=?0;?x?????????????????for?(int?y?=?0;?y?????????????????{
????????????????????Mines[x?y]?=?new?Button();
????????????????????this.Controls.Add(Mines[x?y]);???//增加新按鈕
????????????????????Mines[x?y].Left?=?10?+?MineWidth?*?x;???//定義雷區(qū)開始在Form窗體中的左邊界
????????????????????Mines[x?y].Top?=?65?+?MineWidth?*?y;???//定義雷區(qū)開始在Form窗體中的上邊界
????????????????????Mines[x?y].Width?=?MineWidth;???//定義雷塊的寬度
????????????????????Mines[x?y].Height?=?MineWidth;???//定義雷塊的高度
????????????????????Mines[x?y].Font?=?new?Font(“宋體“?10.5F?Fontstyle.Bold?GraphicsUnit.Point?((byte)(134)));???//定義字體
????????????????????Mines[x?y].BackgroundImageLayout?=?System.Windows.Forms.ImageLayout.Stretch;???//定義backgroundimageLayout
????????????????????Mines[x?y].Name?=?“Mines“?+?(x?+?y?*?XNum).ToString();??
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件????????236??2018-04-21?16:55??掃雷_xxb\掃雷_xxb\bin\Debug\1.PNG
?????文件????????246??2018-04-21?16:55??掃雷_xxb\掃雷_xxb\bin\Debug\2.PNG
?????文件????????231??2018-04-21?16:55??掃雷_xxb\掃雷_xxb\bin\Debug\3.PNG
?????文件????????220??2018-04-21?16:55??掃雷_xxb\掃雷_xxb\bin\Debug\4.PNG
?????文件????????221??2018-04-21?16:55??掃雷_xxb\掃雷_xxb\bin\Debug\5.PNG
?????文件????????217??2018-04-21?16:55??掃雷_xxb\掃雷_xxb\bin\Debug\6.PNG
?????文件????????227??2018-04-21?16:55??掃雷_xxb\掃雷_xxb\bin\Debug\7.PNG
?????文件????????219??2018-04-21?16:55??掃雷_xxb\掃雷_xxb\bin\Debug\8.PNG
?????文件???????4198??2018-04-21?16:55??掃雷_xxb\掃雷_xxb\bin\Debug\face.bmp
?????文件???????1124??2018-04-21?16:55??掃雷_xxb\掃雷_xxb\bin\Debug\face1.jpg
?????文件???????1550??2018-04-21?16:55??掃雷_xxb\掃雷_xxb\bin\Debug\flag.bmp
?????文件???????1710??2018-04-21?16:55??掃雷_xxb\掃雷_xxb\bin\Debug\mine.bmp
?????文件???????2238??2018-04-21?16:55??掃雷_xxb\掃雷_xxb\bin\Debug\mine.ico
?????文件???????1414??2018-04-21?16:55??掃雷_xxb\掃雷_xxb\bin\Debug\mine1.bmp
?????文件??????48640??2018-04-21?16:55??掃雷_xxb\掃雷_xxb\bin\Debug\掃雷_xxb.exe
?????文件??????67072??2018-04-21?16:55??掃雷_xxb\掃雷_xxb\bin\Debug\掃雷_xxb.pdb
?????文件??????14328??2018-04-21?16:55??掃雷_xxb\掃雷_xxb\bin\Debug\掃雷_xxb.vshost.exe
?????文件????????490??2018-04-21?16:55??掃雷_xxb\掃雷_xxb\bin\Debug\掃雷_xxb.vshost.exe.manifest
?????文件?????????49??2018-04-21?16:55??掃雷_xxb\掃雷_xxb\bin\Debug\掃雷英雄榜.txt
?????文件???????1150??2018-04-21?16:55??掃雷_xxb\掃雷_xxb\bin\Debug\勝利.ico
?????文件???????3276??2018-04-21?16:55??掃雷_xxb\掃雷_xxb\bin\Debug\勝利女神.jpg
?????文件??????25029??2018-04-21?16:55??掃雷_xxb\掃雷_xxb\Form1.cs
?????文件??????18828??2018-04-21?16:55??掃雷_xxb\掃雷_xxb\Form1.Designer.cs
?????文件??????15994??2018-04-21?16:55??掃雷_xxb\掃雷_xxb\Form1.resx
?????文件???????1159??2018-04-21?16:55??掃雷_xxb\掃雷_xxb\Form3.cs
?????文件???????4153??2018-04-21?16:55??掃雷_xxb\掃雷_xxb\Form3.Designer.cs
?????文件???????8049??2018-04-21?16:55??掃雷_xxb\掃雷_xxb\Form3.resx
?????文件???????1586??2018-04-21?16:55??掃雷_xxb\掃雷_xxb\Form4.cs
?????文件???????4319??2018-04-21?16:55??掃雷_xxb\掃雷_xxb\Form4.Designer.cs
?????文件???????7846??2018-04-21?16:55??掃雷_xxb\掃雷_xxb\Form4.resx
............此處省略87個(gè)文件信息
評論
共有 條評論