using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace 扫雷
{
public partial class GameForm : Form
{
int num = 0;
const int M = 18, N = 18, BOMPNUM = 80; //方格的横向纵向数量
bool isStart = true; //是否第一次点击方块
bool isLost = false; //是否输掉了本局游戏
bool[,] isClicked = new bool[M, N]; //记录方块是否被点击
bool[,] isLabeled = new bool[M, N]; //记录方块是否被标记
int[,] isBomp = new int[M, N]; //记录方块包含的信息
Button[,] gameBomp = new Button[M, N]; //按钮的方式模拟方块
//窗体构造函数
public GameForm() //窗体构造函数
{
InitializeComponent(); //初始化组件
InitializeGame(); //初始化游戏
}
//初始化本游戏
private void InitializeGame() //游戏的初始化
{
this.Text = "扫雷"; //游戏窗标题
this.Width = 40 + M * 30; //游戏窗宽度
this.Height = 60 + N * 30; //游戏窗高度
this.MaximizeBox = false; //窗体不可最大化
this.StartPosition=FormStartPosition.CenterScreen; //窗口的启动位置
this.FormBorderStyle = FormBorderStyle.FixedSingle; //窗口不可改大小
//按钮控件的添加
for(int i=0;i<M;i++)
{
for(int j=0;j<N;j++)
{
isBomp[i, j] = 0; //初始无地雷
isLabeled[i, j] = false;
isClicked[i, j] = false; //初始不点击
gameBomp[i, j] = new Button();
gameB
C#小游戏之扫雷
最新推荐文章于 2024-05-07 12:42:39 发布