我的编程空间,编程开发者的网络收藏夹
学习永远不晚

C#游戏开发之实现华容道游戏

短信预约 -IT技能 免费直播动态提醒
省份

北京

  • 北京
  • 上海
  • 天津
  • 重庆
  • 河北
  • 山东
  • 辽宁
  • 黑龙江
  • 吉林
  • 甘肃
  • 青海
  • 河南
  • 江苏
  • 湖北
  • 湖南
  • 江西
  • 浙江
  • 广东
  • 云南
  • 福建
  • 海南
  • 山西
  • 四川
  • 陕西
  • 贵州
  • 安徽
  • 广西
  • 内蒙
  • 西藏
  • 新疆
  • 宁夏
  • 兵团
手机号立即预约

请填写图片验证码后获取短信验证码

看不清楚,换张图片

免费获取短信验证码

C#游戏开发之实现华容道游戏

实践过程

效果

代码


public partial class Form1 : Form
{
public Form1()
{
    InitializeComponent();
}

private Panel pl;//记录选中的控件ID

private void Form1_Load(object sender, EventArgs e)
{
    //初始化时设置各个位置的可用状态
    PlState[0, 0] = PlState[0, 1] = PlState[0, 2] = PlState[0, 3] =
        PlState[1, 0] = PlState[1, 1] = PlState[1, 2] = PlState[1, 3] =
        PlState[2, 0] = PlState[2, 1] = PlState[2, 2] = PlState[2, 3] =
        PlState[3, 0] = PlState[3, 1] = PlState[3, 2] = PlState[3, 3] =
        PlState[4, 0] = PlState[4, 3] = true;
}

//初始化各人物方格位置
private void button1_Click(object sender, EventArgs e)
{
    //设置各方格的初始图片
    panel1.BackgroundImage = (Image)(Properties.Resources._003);
    panel2.BackgroundImage = (Image)(Properties.Resources._001);
    panel3.BackgroundImage = (Image)(Properties.Resources._004);
    panel4.BackgroundImage = (Image)(Properties.Resources._005);
    panel5.BackgroundImage = (Image)(Properties.Resources._002);
    panel6.BackgroundImage = (Image)(Properties.Resources._006);
    panel7.BackgroundImage = (Image)(Properties.Resources._007);
    panel8.BackgroundImage = (Image)(Properties.Resources._008);
    panel9.BackgroundImage = (Image)(Properties.Resources._009);
    panel10.BackgroundImage = (Image)(Properties.Resources._010);
    //设置各方格的初始位置
    panel1.Location = position[0, 0];
    panel2.Location = position[0, 1];
    panel3.Location = position[0, 3];
    panel4.Location = position[2, 0];
    panel5.Location = position[2, 1];
    panel6.Location = position[2, 3];
    panel7.Location = position[3, 1];
    panel8.Location = position[3, 2];
    panel9.Location = position[4, 0];
    panel10.Location = position[4, 3];
    PlState[4, 0] = PlState[4, 3] = true;   //设置最后一行的首尾位置不可用
    PlState[4, 1] = PlState[4, 2] = false;  //设置最后一行的中间两个位置可用
}

#region 赵云
private void panel1_Click(object sender, EventArgs e)
{
    //设置各方格图片
    panel1.BackgroundImage = (Image)(Properties.Resources.a3);
    panel2.BackgroundImage = (Image)(Properties.Resources._001);
    panel3.BackgroundImage = (Image)(Properties.Resources._004);
    panel4.BackgroundImage = (Image)(Properties.Resources._005);
    panel5.BackgroundImage = (Image)(Properties.Resources._002);
    panel6.BackgroundImage = (Image)(Properties.Resources._006);
    panel7.BackgroundImage = (Image)(Properties.Resources._007);
    panel8.BackgroundImage = (Image)(Properties.Resources._008);
    panel9.BackgroundImage = (Image)(Properties.Resources._009);
    panel10.BackgroundImage = (Image)(Properties.Resources._010);
    PStyle = PStyles.P2V;//记录方格样式
    pl = panel1;         //记录选中的控件ID
    PosX = intX(panel1); //记录选中控件在坐标数组中的列索引
    PosY = intY(panel1); //记录选中控件在坐标数组中的行索引
}
#endregion

#region 曹操
private void panel2_Click(object sender, EventArgs e)
{
    panel1.BackgroundImage = (Image)(Properties.Resources._003);
    panel2.BackgroundImage = (Image)(Properties.Resources.a1);
    panel3.BackgroundImage = (Image)(Properties.Resources._004);
    panel4.BackgroundImage = (Image)(Properties.Resources._005);
    panel5.BackgroundImage = (Image)(Properties.Resources._002);
    panel6.BackgroundImage = (Image)(Properties.Resources._006);
    panel7.BackgroundImage = (Image)(Properties.Resources._007);
    panel8.BackgroundImage = (Image)(Properties.Resources._008);
    panel9.BackgroundImage = (Image)(Properties.Resources._009);
    panel10.BackgroundImage = (Image)(Properties.Resources._010);
    PStyle = PStyles.P4;
    pl = panel2;
    PosX = intX(panel2);
    PosY = intY(panel2);
}
#endregion

#region 张飞
private void panel3_Click(object sender, EventArgs e)
{
    panel1.BackgroundImage = (Image)(Properties.Resources._003);
    panel2.BackgroundImage = (Image)(Properties.Resources._001);
    panel3.BackgroundImage = (Image)(Properties.Resources.a4);
    panel4.BackgroundImage = (Image)(Properties.Resources._005);
    panel5.BackgroundImage = (Image)(Properties.Resources._002);
    panel6.BackgroundImage = (Image)(Properties.Resources._006);
    panel7.BackgroundImage = (Image)(Properties.Resources._007);
    panel8.BackgroundImage = (Image)(Properties.Resources._008);
    panel9.BackgroundImage = (Image)(Properties.Resources._009);
    panel10.BackgroundImage = (Image)(Properties.Resources._010);
    PStyle = PStyles.P2V;
    pl = panel3;
    PosX = intX(panel3);
    PosY = intY(panel3);
}
#endregion

#region 马超
private void panel4_Click(object sender, EventArgs e)
{
    panel1.BackgroundImage = (Image)(Properties.Resources._003);
    panel2.BackgroundImage = (Image)(Properties.Resources._001);
    panel3.BackgroundImage = (Image)(Properties.Resources._004);
    panel4.BackgroundImage = (Image)(Properties.Resources.a5);
    panel5.BackgroundImage = (Image)(Properties.Resources._002);
    panel6.BackgroundImage = (Image)(Properties.Resources._006);
    panel7.BackgroundImage = (Image)(Properties.Resources._007);
    panel8.BackgroundImage = (Image)(Properties.Resources._008);
    panel9.BackgroundImage = (Image)(Properties.Resources._009);
    panel10.BackgroundImage = (Image)(Properties.Resources._010);
    PStyle = PStyles.P2V;
    pl = panel4;
    PosX = intX(panel4);
    PosY = intY(panel4);
}
#endregion

#region 关羽
private void panel5_Click(object sender, EventArgs e)
{
    panel1.BackgroundImage = (Image)(Properties.Resources._003);
    panel2.BackgroundImage = (Image)(Properties.Resources._001);
    panel3.BackgroundImage = (Image)(Properties.Resources._004);
    panel4.BackgroundImage = (Image)(Properties.Resources._005);
    panel5.BackgroundImage = (Image)(Properties.Resources.a2);
    panel6.BackgroundImage = (Image)(Properties.Resources._006);
    panel7.BackgroundImage = (Image)(Properties.Resources._007);
    panel8.BackgroundImage = (Image)(Properties.Resources._008);
    panel9.BackgroundImage = (Image)(Properties.Resources._009);
    panel10.BackgroundImage = (Image)(Properties.Resources._010);
    PStyle = PStyles.P2H;
    pl = panel5;
    PosX = intX(panel5);
    PosY = intY(panel5);
}
#endregion

#region 黄忠
private void panel6_Click(object sender, EventArgs e)
{
    panel1.BackgroundImage = (Image)(Properties.Resources._003);
    panel2.BackgroundImage = (Image)(Properties.Resources._001);
    panel3.BackgroundImage = (Image)(Properties.Resources._004);
    panel4.BackgroundImage = (Image)(Properties.Resources._005);
    panel5.BackgroundImage = (Image)(Properties.Resources._002);
    panel6.BackgroundImage = (Image)(Properties.Resources.a6);
    panel7.BackgroundImage = (Image)(Properties.Resources._007);
    panel8.BackgroundImage = (Image)(Properties.Resources._008);
    panel9.BackgroundImage = (Image)(Properties.Resources._009);
    panel10.BackgroundImage = (Image)(Properties.Resources._010);
    PStyle = PStyles.P2V;
    pl = panel6;
    PosX = intX(panel6);
    PosY = intY(panel6);
}
#endregion

#region 士兵一
private void panel7_Click(object sender, EventArgs e)
{
    panel1.BackgroundImage = (Image)(Properties.Resources._003);
    panel2.BackgroundImage = (Image)(Properties.Resources._001);
    panel3.BackgroundImage = (Image)(Properties.Resources._004);
    panel4.BackgroundImage = (Image)(Properties.Resources._005);
    panel5.BackgroundImage = (Image)(Properties.Resources._002);
    panel6.BackgroundImage = (Image)(Properties.Resources._006);
    panel7.BackgroundImage = (Image)(Properties.Resources.a7);
    panel8.BackgroundImage = (Image)(Properties.Resources._008);
    panel9.BackgroundImage = (Image)(Properties.Resources._009);
    panel10.BackgroundImage = (Image)(Properties.Resources._010);
    PStyle = PStyles.P1;
    pl = panel7;
    PosX = intX(panel7);
    PosY = intY(panel7);
}
#endregion

#region 士兵二
private void panel8_Click(object sender, EventArgs e)
{
    panel1.BackgroundImage = (Image)(Properties.Resources._003);
    panel2.BackgroundImage = (Image)(Properties.Resources._001);
    panel3.BackgroundImage = (Image)(Properties.Resources._004);
    panel4.BackgroundImage = (Image)(Properties.Resources._005);
    panel5.BackgroundImage = (Image)(Properties.Resources._002);
    panel6.BackgroundImage = (Image)(Properties.Resources._006);
    panel7.BackgroundImage = (Image)(Properties.Resources._007);
    panel8.BackgroundImage = (Image)(Properties.Resources.a8);
    panel9.BackgroundImage = (Image)(Properties.Resources._009);
    panel10.BackgroundImage = (Image)(Properties.Resources._010);
    PStyle = PStyles.P1;
    pl = panel8;
    PosX = intX(panel8);
    PosY = intY(panel8);
}
#endregion

#region 士兵三
private void panel9_Click(object sender, EventArgs e)
{
    panel1.BackgroundImage = (Image)(Properties.Resources._003);
    panel2.BackgroundImage = (Image)(Properties.Resources._001);
    panel3.BackgroundImage = (Image)(Properties.Resources._004);
    panel4.BackgroundImage = (Image)(Properties.Resources._005);
    panel5.BackgroundImage = (Image)(Properties.Resources._002);
    panel6.BackgroundImage = (Image)(Properties.Resources._006);
    panel7.BackgroundImage = (Image)(Properties.Resources._007);
    panel8.BackgroundImage = (Image)(Properties.Resources._008);
    panel9.BackgroundImage = (Image)(Properties.Resources.a9);
    panel10.BackgroundImage = (Image)(Properties.Resources._010);
    PStyle = PStyles.P1;
    pl = panel9;
    PosX = intX(panel9);
    PosY = intY(panel9);
}
#endregion

#region 士兵四
private void panel10_Click(object sender, EventArgs e)
{
    panel1.BackgroundImage = (Image)(Properties.Resources._003);
    panel2.BackgroundImage = (Image)(Properties.Resources._001);
    panel3.BackgroundImage = (Image)(Properties.Resources._004);
    panel4.BackgroundImage = (Image)(Properties.Resources._005);
    panel5.BackgroundImage = (Image)(Properties.Resources._002);
    panel6.BackgroundImage = (Image)(Properties.Resources._006);
    panel7.BackgroundImage = (Image)(Properties.Resources._007);
    panel8.BackgroundImage = (Image)(Properties.Resources._008);
    panel9.BackgroundImage = (Image)(Properties.Resources._009);
    panel10.BackgroundImage = (Image)(Properties.Resources.a10);
    PStyle = PStyles.P1;
    pl = panel10;
    PosX = intX(panel10);
    PosY = intY(panel10);
}
#endregion

#region 判断是否成功
///<summary>
///判断是否成功
///</summary>
///<returns>true表示成功,false表示失败</returns>
private bool Successful()
{
    if (panel2.Location == new Point(108, 343))
    {
        MessageBox.Show("恭喜你,曹操已经成功逃离华容道!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
        return true;
    }
    else
        return false;
}
#endregion

//通过按键盘上的上、下、左、右键来移动人物方格
private void Form1_KeyUp(object sender, KeyEventArgs e)
{
    blUp = blDown = blLeft = blRight = false;//设置上、下、左、右方向移动不可用  
    switch (e.KeyData)
    {
        case Keys.Up:       //向上移动
            blUp = true;
            break;
        case Keys.Down:     //向下移动
            blDown = true;
            break;
        case Keys.Left:     //向左移动
            blLeft = true;
            break;
        case Keys.Right:    //向右移动
            blRight = true;
            break;
    }
    MovePosition(pl, PosX, PosY);//移动人物方格位置
    if (Successful())//判断是否成功
        button1_Click(sender, e);//重新开始
}

//定义每个人物方格的大小, 共有x*y(x=4, y=5)个人物方格
public enum plEnumerate : int
{
    plSize = 100,   //人物方格大小
    plX = 4,        //定义列
    plY = 5,        //定义行
};

//判断索引位置是否可用
public bool[,] PlState = new bool[(int)plEnumerate.plY, (int)plEnumerate.plX];

//定义一个数组,用来记录各人物方格位置
private Point[,] position = new Point[5, 4] {
    { new Point(8, 43), new Point(108, 43), new Point(208, 43), new Point(308, 43) },
    { new Point(8, 143), new Point(108, 143), new Point(208, 143), new Point(308, 143) },
    { new Point(8, 243), new Point(108, 243), new Point(208, 243), new Point(308, 243) },
    { new Point(8, 343), new Point(108, 343), new Point(208, 343), new Point(308, 343) },
    { new Point(8, 443), new Point(108, 443), new Point(208, 443), new Point(308, 443) },
};

//获取人物方格的位置
public Point[,] GetPosition()
{
    return this.position;
}

//定义各人物方格的形状
public enum PStyles : int
{
    P1 = 0,//口
    P4 = 1,//田
    P2V = 2,//日
    P2H = 3,//口口
};

private int m_PStyle;//获取人物样式的编号

//记录人物样式形状
public PStyles PStyle
{
    get { return (PStyles)this.m_PStyle; }
    set { this.m_PStyle = (int)value; }
}

private int m_X = 0, m_Y = 0;//记录人物方格索引

//返回人物方格列索引
public int PosX
{
    get { return this.m_X; }
    set { this.m_X = value; }
}

//返回人物方格行索引
public int PosY
{
    get { return this.m_Y; }
    set { this.m_Y = value; }
}

#region 计算选中的人物方格在数组中的列索引
///<summary>
///计算选中的人物方格在数组中的列索引
///</summary>
///<param name="pl">选中的Panel控件</param>
///<returns>列索引</returns>
private int intX(Panel pl)
{
    int i = pl.Location.X - 8;
    return i / 100;
}
#endregion

#region 计算选中的人物方格在数组中的行索引
///<summary>
///计算选中的人物方格在数组中的行索引
///</summary>
///<param name="pl">选中的Panel控件</param>
///<returns>行索引</returns>
private int intY(Panel pl)
{
    int i = pl.Location.Y - 43;
    return i / 100;
}
#endregion

//定义4个变量,分别用来表示向上、下、左、右移动
private bool blUp, blDown, blLeft, blRight;

#region 移动人物位置
///<summary>
///移动人物位置
///</summary>
///<param name="pl">要移动的控件名称</param>
///<param name="x">横坐标在坐标数组中的索引</param>
///<param name="y">纵坐标在坐标数组中的索引</param>
///<returns>是否移动成功</returns>
public bool MovePosition(Panel pl, int x, int y)
{
    #region 上移
    if (blUp && (y - 1) >= 0)
    {
        switch (PStyle)
        {
            case PStyles.P4://田
            case PStyles.P2H://口口
                if (!PlState[y - 1, x] && !PlState[y - 1, x + 1])
                {
                    pl.Location = GetPosition()[y - 1, x];
                    if (PStyle == PStyles.P4)//田
                    {
                        PlState[y + 1, x] = false;
                        PlState[y + 1, x + 1] = false;
                    }
                    else if (PStyle == PStyles.P2H)//口口
                    {
                        PlState[y, x] = false;
                        PlState[y, x + 1] = false;
                    }
                    PlState[y - 1, x] = true;
                    PlState[y - 1, x + 1] = true;
                    PosY -= 1;
                    return true;
                }
                else return false;
            case PStyles.P2V://日
            case PStyles.P1://口
                if (!PlState[y - 1, x])
                {
                    pl.Location = GetPosition()[y - 1, x];
                    if (PStyle == PStyles.P2V)//日
                    {
                        PlState[y + 1, x] = false;
                    }
                    else if (PStyle == PStyles.P1)//口
                    {
                        PlState[y, x] = false;
                    }
                    PlState[y - 1, x] = true;
                    PosY -= 1;
                    return true;
                }
                else return false;
        }
    }
    #endregion
    #region 下移
    else if (blDown)
    {
        switch (PStyle)
        {
            case PStyles.P4://田
                if ((y + 2) < (int)plEnumerate.plY && !PlState[y + 2, x] && !PlState[y + 2, x + 1])
                {
                    pl.Location = GetPosition()[y + 1, x];
                    PlState[y, x] = false;
                    PlState[y, x + 1] = false;
                    PlState[y + 2, x] = true;
                    PlState[y + 2, x + 1] = true;
                    PosY += 1;
                    return true;
                }
                else return false;
            case PStyles.P2V://日
                if ((y + 2) < (int)plEnumerate.plY && !PlState[y + 2, x])
                {
                    pl.Location = GetPosition()[y + 1, x];
                    PlState[y, x] = false;
                    PlState[y + 2, x] = true;
                    PosY += 1;
                    return true;
                }
                else return false;
            case PStyles.P1://口
                if ((y + 1) < (int)plEnumerate.plY && !PlState[y + 1, x])
                {
                    pl.Location = GetPosition()[y + 1, x];
                    PlState[y, x] = false;
                    PlState[y + 1, x] = true;
                    PosY += 1;
                    return true;
                }
                else return false;
            case PStyles.P2H://口口
                if ((y + 1) < (int)plEnumerate.plY && !PlState[y + 1, x] && !PlState[y + 1, x + 1])
                {
                    pl.Location = GetPosition()[y + 1, x];
                    PlState[y, x] = false;
                    PlState[y, x + 1] = false;
                    PlState[y + 1, x] = true;
                    PlState[y + 1, x + 1] = true;
                    PosY += 1;
                    return true;
                }
                else return false;
        }
    }
    #endregion
    #region 左移
    else if (blLeft)
    {
        switch (PStyle)
        {
            case PStyles.P2V://日
            case PStyles.P4://田
                if (x - 1 >= 0 && !PlState[y, x - 1] && !PlState[y + 1, x - 1])
                {
                    pl.Location = GetPosition()[y, x - 1];
                    switch (PStyle)
                    {
                        case PStyles.P4://田
                            PlState[y, x + 1] = false;
                            PlState[y + 1, x + 1] = false;
                            break;

                        case PStyles.P2V://日
                            PlState[y, x] = false;
                            PlState[y + 1, x] = false;
                            break;
                    }
                    PlState[y, x - 1] = true;
                    PlState[y + 1, x - 1] = true;
                    PosX -= 1;
                    return true;
                }
                else return false;
            case PStyles.P1://口
            case PStyles.P2H://口口
                if (x - 1 >= 0 && !PlState[y, x - 1])
                {
                    pl.Location = GetPosition()[y, x - 1];
                    if (PStyle == PStyles.P2H)//口口
                    {
                        PlState[y, x + 1] = false;
                    }
                    else
                    {
                        PlState[y, x] = false;
                    }
                    PlState[y, x - 1] = true;
                    PosX -= 1;
                    return true;
                }
                else return false;
        }
    }
    #endregion
    #region 右移
    else if (blRight)
    {
        switch (PStyle)
        {
            case PStyles.P4://田
                if (x + 2 < (int)plEnumerate.plX && !PlState[y, x + 2] && !PlState[y + 1, x + 2])
                {
                    pl.Location = GetPosition()[y, x + 1];
                    PlState[y, x] = false;
                    PlState[y + 1, x] = false;
                    PlState[y, x + 2] = true;
                    PlState[y + 1, x + 2] = true;
                    PosX += 1;
                    return true;
                }
                else return false;
            case PStyles.P1://口
                if (x + 1 < (int)plEnumerate.plX && !PlState[y, x + 1])
                {
                    pl.Location = GetPosition()[y, x + 1];
                    PlState[y, x] = false;
                    PlState[y, x + 1] = true;
                    PosX += 1;
                    return true;
                }
                else return false;
            case PStyles.P2H://口口
                if (x + 2 < (int)plEnumerate.plX && !PlState[y, x + 2])
                {
                    pl.Location = GetPosition()[y, x + 1];
                    PlState[y, x] = false;
                    PlState[y, x + 2] = true;
                    PosX += 1;
                    return true;
                }
                else return false;
            case PStyles.P2V://日
                if (x + 1 < (int)plEnumerate.plX && !PlState[y, x + 1] && !PlState[y + 1, x + 1])
                {
                    pl.Location = GetPosition()[y, x + 1];
                    PlState[y, x] = false;
                    PlState[y + 1, x] = false;
                    PlState[y, x + 1] = true;
                    PlState[y + 1, x + 1] = true;
                    PosX += 1;
                    return true;
                }
                else return false;
        }
    }
    #endregion
    return false;
}      
#endregion
}
partial class Form1
{
    /// <summary>
    /// 必需的设计器变量。
    /// </summary>
    private System.ComponentModel.IContainer components = null;

    /// <summary>
    /// 清理所有正在使用的资源。
    /// </summary>
    /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
    protected override void Dispose(bool disposing)
    {
        if (disposing && (components != null))
        {
            components.Dispose();
        }
        base.Dispose(disposing);
    }

    #region Windows 窗体设计器生成的代码

    /// <summary>
    /// 设计器支持所需的方法 - 不要
    /// 使用代码编辑器修改此方法的内容。
    /// </summary>
    private void InitializeComponent()
    {
        this.panel1 = new System.Windows.Forms.Panel();
        this.panel2 = new System.Windows.Forms.Panel();
        this.panel3 = new System.Windows.Forms.Panel();
        this.panel4 = new System.Windows.Forms.Panel();
        this.panel5 = new System.Windows.Forms.Panel();
        this.panel6 = new System.Windows.Forms.Panel();
        this.panel7 = new System.Windows.Forms.Panel();
        this.panel8 = new System.Windows.Forms.Panel();
        this.panel9 = new System.Windows.Forms.Panel();
        this.panel10 = new System.Windows.Forms.Panel();
        this.button1 = new System.Windows.Forms.Button();
        this.SuspendLayout();
        // 
        // panel1
        // 
        this.panel1.BackgroundImage = global::HuaRongDao.Properties.Resources._003;
        this.panel1.Location = new System.Drawing.Point(8, 43);
        this.panel1.Name = "panel1";
        this.panel1.Size = new System.Drawing.Size(100, 200);
        this.panel1.TabIndex = 0;
        this.panel1.Click += new System.EventHandler(this.panel1_Click);
        // 
        // panel2
        // 
        this.panel2.BackgroundImage = global::HuaRongDao.Properties.Resources._001;
        this.panel2.Location = new System.Drawing.Point(108, 43);
        this.panel2.Name = "panel2";
        this.panel2.Size = new System.Drawing.Size(200, 200);
        this.panel2.TabIndex = 0;
        this.panel2.Click += new System.EventHandler(this.panel2_Click);
        // 
        // panel3
        // 
        this.panel3.BackgroundImage = global::HuaRongDao.Properties.Resources._004;
        this.panel3.Location = new System.Drawing.Point(308, 43);
        this.panel3.Name = "panel3";
        this.panel3.Size = new System.Drawing.Size(100, 200);
        this.panel3.TabIndex = 1;
        this.panel3.Click += new System.EventHandler(this.panel3_Click);
        // 
        // panel4
        // 
        this.panel4.BackgroundImage = global::HuaRongDao.Properties.Resources._005;
        this.panel4.Location = new System.Drawing.Point(8, 243);
        this.panel4.Name = "panel4";
        this.panel4.Size = new System.Drawing.Size(100, 200);
        this.panel4.TabIndex = 2;
        this.panel4.Click += new System.EventHandler(this.panel4_Click);
        // 
        // panel5
        // 
        this.panel5.BackgroundImage = global::HuaRongDao.Properties.Resources._002;
        this.panel5.Location = new System.Drawing.Point(108, 243);
        this.panel5.Name = "panel5";
        this.panel5.Size = new System.Drawing.Size(200, 100);
        this.panel5.TabIndex = 3;
        this.panel5.Click += new System.EventHandler(this.panel5_Click);
        // 
        // panel6
        // 
        this.panel6.BackgroundImage = global::HuaRongDao.Properties.Resources._006;
        this.panel6.Location = new System.Drawing.Point(308, 243);
        this.panel6.Name = "panel6";
        this.panel6.Size = new System.Drawing.Size(100, 200);
        this.panel6.TabIndex = 4;
        this.panel6.Click += new System.EventHandler(this.panel6_Click);
        // 
        // panel7
        // 
        this.panel7.BackgroundImage = global::HuaRongDao.Properties.Resources._007;
        this.panel7.Location = new System.Drawing.Point(108, 343);
        this.panel7.Name = "panel7";
        this.panel7.Size = new System.Drawing.Size(100, 100);
        this.panel7.TabIndex = 5;
        this.panel7.Click += new System.EventHandler(this.panel7_Click);
        // 
        // panel8
        // 
        this.panel8.BackgroundImage = global::HuaRongDao.Properties.Resources._008;
        this.panel8.Location = new System.Drawing.Point(208, 343);
        this.panel8.Name = "panel8";
        this.panel8.Size = new System.Drawing.Size(100, 100);
        this.panel8.TabIndex = 6;
        this.panel8.Click += new System.EventHandler(this.panel8_Click);
        // 
        // panel9
        // 
        this.panel9.BackgroundImage = global::HuaRongDao.Properties.Resources._009;
        this.panel9.Location = new System.Drawing.Point(8, 443);
        this.panel9.Name = "panel9";
        this.panel9.Size = new System.Drawing.Size(100, 100);
        this.panel9.TabIndex = 7;
        this.panel9.Click += new System.EventHandler(this.panel9_Click);
        // 
        // panel10
        // 
        this.panel10.BackgroundImage = global::HuaRongDao.Properties.Resources._010;
        this.panel10.Location = new System.Drawing.Point(308, 443);
        this.panel10.Name = "panel10";
        this.panel10.Size = new System.Drawing.Size(100, 100);
        this.panel10.TabIndex = 8;
        this.panel10.Click += new System.EventHandler(this.panel10_Click);
        // 
        // button1
        // 
        this.button1.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
        this.button1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
        this.button1.ForeColor = System.Drawing.Color.White;
        this.button1.Location = new System.Drawing.Point(11, 9);
        this.button1.Name = "button1";
        this.button1.Size = new System.Drawing.Size(75, 25);
        this.button1.TabIndex = 0;
        this.button1.Text = "新游戏";
        this.button1.UseVisualStyleBackColor = true;
        this.button1.Click += new System.EventHandler(this.button1_Click);
        // 
        // Form1
        // 
        this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
        this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
        this.BackColor = System.Drawing.Color.Teal;
        this.ClientSize = new System.Drawing.Size(413, 550);
        this.Controls.Add(this.button1);
        this.Controls.Add(this.panel10);
        this.Controls.Add(this.panel9);
        this.Controls.Add(this.panel8);
        this.Controls.Add(this.panel7);
        this.Controls.Add(this.panel6);
        this.Controls.Add(this.panel5);
        this.Controls.Add(this.panel4);
        this.Controls.Add(this.panel3);
        this.Controls.Add(this.panel2);
        this.Controls.Add(this.panel1);
        this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
        this.KeyPreview = true;
        this.MaximizeBox = false;
        this.Name = "Form1";
        this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
        this.Text = "华容道";
        this.Load += new System.EventHandler(this.Form1_Load);
        this.KeyUp += new System.Windows.Forms.KeyEventHandler(this.Form1_KeyUp);
        this.ResumeLayout(false);

    }

    #endregion

    private System.Windows.Forms.Panel panel1;
    private System.Windows.Forms.Panel panel2;
    private System.Windows.Forms.Panel panel3;
    private System.Windows.Forms.Panel panel4;
    private System.Windows.Forms.Panel panel5;
    private System.Windows.Forms.Panel panel6;
    private System.Windows.Forms.Panel panel7;
    private System.Windows.Forms.Panel panel8;
    private System.Windows.Forms.Panel panel9;
    private System.Windows.Forms.Panel panel10;
    private System.Windows.Forms.Button button1;
}

以上就是C#游戏开发之实现华容道游戏的详细内容,更多关于C#华容道的资料请关注编程网其它相关文章!

免责声明:

① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。

② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341

C#游戏开发之实现华容道游戏

下载Word文档到电脑,方便收藏和打印~

下载Word文档

猜你喜欢

C#游戏开发之实现华容道游戏

这篇文章主要为大家详细介绍了C#如何实现经典华容道游戏,文中的示例代码讲解详细,对我们学习C#有一定的帮助,感兴趣的小伙伴可以跟随小编一起了解一下
2023-01-04

C#游戏开发之实现贪吃蛇游戏

这篇文章主要为大家详细介绍了C#如何实现经典贪吃蛇游戏,文中的示例代码讲解详细,对我们学习C#有一定的帮助,感兴趣的小伙伴可以跟随小编一起了解一下
2023-01-04

C#游戏开发之实现俄罗斯方块游戏

这篇文章主要为大家详细介绍了C#如何实现经典俄罗斯方块游戏,文中的示例代码讲解详细,对我们学习C#有一定的帮助,感兴趣的小伙伴可以跟随小编一起了解一下
2023-01-05

如何使用C#实现数字华容道游戏

这篇文章主要介绍如何使用C#实现数字华容道游戏,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!具体内容如下代码如下:using System;using System.Collections.Generic;using
2023-06-29

如何基于C#的winform实现数字华容道游戏

这篇文章给大家分享的是有关如何基于C#的winform实现数字华容道游戏的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。数字华容道游戏类似于拼图游戏,只需将数字1~15按顺序排好即可。该游戏逻辑比较简单,易于编程实
2023-06-29

基于C语言自制华容道游戏怎么实现

这篇文章主要介绍“基于C语言自制华容道游戏怎么实现”的相关知识,小编通过实际案例向大家展示操作过程,操作方法简单快捷,实用性强,希望这篇“基于C语言自制华容道游戏怎么实现”文章能帮助大家解决问题。程序执行效果完整源代码// 程序:华容道//
2023-07-05

Python开发游戏之井字游戏的实战步骤

最近正在学习Python,所以最近做了一个关于Python的实例,下面这篇文章主要给大家介绍了关于Python开发游戏之井字游戏的相关资料,文中通过实例代码介绍的非常详细,需要的朋友可以参考下
2023-02-04

C++小游戏教程之猜数游戏的实现

这篇文章主要和大家详细介绍如何利用C++做一个简易的猜数游戏,分为用户猜数和系统猜数。文中的示例代码讲解详细,感兴趣的小伙伴可以尝试一下
2022-11-13

Android实现疯狂连连看游戏之开发游戏界面(二)

连连看的游戏界面十分简单,大致可以分为两个区域: --游戏主界面区 --控制按钮和数据显示区1、开发界面布局本程序使用一个RelativeLayout作为整体的界面布局元素,界面布局上面是一个自定义组件,下面是一个水平排列的LinearLa
2022-06-06

Python游戏开发:最强大脑第一关,数字华容道

前言freegames是Apache2许可的免费Python游戏集合,旨在用于教育和娱乐,完全是开源的,我们只要引用编写就好,当前在最强大脑的舞台上的第一关就是数字华容道,好多人都栽在了上面,如果你也想试试,就来看看是如何实现的把今天为大家
2023-06-02

探索Unity3D游戏引擎,开启游戏开发之旅(Unity3D游戏引擎在游戏开发中的应用与探索)

Unity3D是一款跨平台游戏引擎,广泛应用于各类游戏开发,包括3D、2D、移动、VR和AR游戏。其优势在于跨平台支持、强大的图形渲染、物理引擎、友好的用户界面和丰富的工具集。探索Unity3D可通过在线教程、官方文档、社区论坛、资产商店和创建游戏原型等方式,帮助开发人员深入了解引擎的工作原理并将其应用于游戏开发中。
探索Unity3D游戏引擎,开启游戏开发之旅(Unity3D游戏引擎在游戏开发中的应用与探索)
2024-04-02

Android 之游戏开发流程

游戏开发流程在不同的项目中会有一些差异,但是一般来说,Android 游戏开发流程可以大致分为以下几个步骤:1. 设计阶段:在这个阶段,你需要确定游戏的类型,玩法以及整体的游戏设计。你可以创建一个游戏概念,制定游戏规则,设计游戏界面和角色等
2023-09-28

编程热搜

  • Python 学习之路 - Python
    一、安装Python34Windows在Python官网(https://www.python.org/downloads/)下载安装包并安装。Python的默认安装路径是:C:\Python34配置环境变量:【右键计算机】--》【属性】-
    Python 学习之路 - Python
  • chatgpt的中文全称是什么
    chatgpt的中文全称是生成型预训练变换模型。ChatGPT是什么ChatGPT是美国人工智能研究实验室OpenAI开发的一种全新聊天机器人模型,它能够通过学习和理解人类的语言来进行对话,还能根据聊天的上下文进行互动,并协助人类完成一系列
    chatgpt的中文全称是什么
  • C/C++中extern函数使用详解
  • C/C++可变参数的使用
    可变参数的使用方法远远不止以下几种,不过在C,C++中使用可变参数时要小心,在使用printf()等函数时传入的参数个数一定不能比前面的格式化字符串中的’%’符号个数少,否则会产生访问越界,运气不好的话还会导致程序崩溃
    C/C++可变参数的使用
  • css样式文件该放在哪里
  • php中数组下标必须是连续的吗
  • Python 3 教程
    Python 3 教程 Python 的 3.0 版本,常被称为 Python 3000,或简称 Py3k。相对于 Python 的早期版本,这是一个较大的升级。为了不带入过多的累赘,Python 3.0 在设计的时候没有考虑向下兼容。 Python
    Python 3 教程
  • Python pip包管理
    一、前言    在Python中, 安装第三方模块是通过 setuptools 这个工具完成的。 Python有两个封装了 setuptools的包管理工具: easy_install  和  pip , 目前官方推荐使用 pip。    
    Python pip包管理
  • ubuntu如何重新编译内核
  • 改善Java代码之慎用java动态编译

目录