| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 374 人关注过本帖
标题:大家帮我用中文注解一下啊,谢谢
只看楼主 加入收藏
可爱的毛毛
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2010-6-10
结帖率:0
收藏
 问题点数:0 回复次数:0 
大家帮我用中文注解一下啊,谢谢
namespace MySnake
{
    public partial class frmGame : Form
    {
        private Controller objController;
        private Snake objSnake;
        private string strUp = "";
        private string strDown = "";
        private string strLeft = "";
        private string strRight = "";

        private bool blIsGameStart;

        public frmGame()
        {
            InitializeComponent();
        }

        private void frmGame_Load(object sender, EventArgs e)
        {
            blIsGameStart = false;

            Config objConfig = new Config();
            strUp = objConfig.GetConfigValue("Up");
            strDown = objConfig.GetConfigValue("Down");
            strLeft = objConfig.GetConfigValue("Left");
            strRight = objConfig.GetConfigValue("Right");

            lblUp.Text = strUp;
            lblDown.Text = strDown;
            lblLeft.Text = strLeft;
            lblRight.Text = strRight;
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            objController.Move();

            if (objController.IsGameOver)
            {
                timer1.Enabled = false;
                开始ToolStripMenuItem.Enabled = true;
                暂停ToolStripMenuItem.Enabled = false;
                MessageBox.Show("Game Over");
            }
            else
            {
                if (objController.IsGetTarget)
                {
                    lblTargetCount.Text = objController.TargetCount.ToString();
                    lblSnakeLength.Text = objSnake.Length.ToString();
                    lblScore.Text = objController.Score.ToString();
                    lblSpeedLevel.Text = objSnake.Speed.ToString();
                    timer1.Interval = 245 - objSnake.Speed * 20;
                }
            }
        }

        private void 暂停ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            timer1.Enabled = !timer1.Enabled;
        }

        private void 退出ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void 开始ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (objController != null)
            {
                objController.ClearSnake();
            }
            initializeSnake();

            timer1.Enabled = true;
            开始ToolStripMenuItem.Enabled = false;
            暂停ToolStripMenuItem.Enabled = true;
            结束游戏ToolStripMenuItem.Enabled = true;
        }

        private void initializeSnake()
        {
            objSnake = new Snake();
            objController = new Controller(plGame, objSnake);
            lblDirection.Text = "向右";
            lblSnakeLength.Text = "6";
            lblTargetCount.Text = "0";

            timer1.Interval = 245 - objSnake.Speed * 20;

            Config objConfig = new Config();
            strUp = objConfig.GetConfigValue("Up");
            strDown = objConfig.GetConfigValue("Down");
            strLeft = objConfig.GetConfigValue("Left");
            strRight = objConfig.GetConfigValue("Right");

            lblUp.Text = strUp;
            lblDown.Text = strDown;
            lblLeft.Text = strLeft;
            lblRight.Text = strRight;

            objController.InitializeSnake();
            blIsGameStart = true;
        }

        private void 结束游戏ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            timer1.Enabled = false;
            开始ToolStripMenuItem.Enabled = true;
            暂停ToolStripMenuItem.Enabled = false;
            结束游戏ToolStripMenuItem.Enabled = false;
        }

        private void frmGame_KeyDown(object sender, KeyEventArgs e)
        {
            string strKey = e.KeyData.ToString();

            if (strKey == strUp)
            {
                if (objSnake.Direction != "D")
                {
                    objSnake.Direction = "U";
                    lblDirection.Text = "向上";
                }
            }
            else if (strKey == strLeft)
            {
                if (objSnake.Direction != "R")
                {
                    objSnake.Direction = "L";
                    lblDirection.Text = "向左";
                }
            }
            else if (strKey == strDown)
            {
                if (objSnake.Direction != "U")
                {
                    objSnake.Direction = "D";
                    lblDirection.Text = "向下";
                }
            }
            else if (strKey == strRight)
            {
                if (objSnake.Direction != "L")
                {
                    objSnake.Direction = "R";
                    lblDirection.Text = "向右";
                }
            }
        }

        private void frmGame_Paint(object sender, PaintEventArgs e)
        {
            if (blIsGameStart)
            {
                objController.DrawSnakeAndTarget();
            }
        }

        private void 游戏设置ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmSettings objFrm = new frmSettings();
            objFrm.ShowDialog();
        }

        private void 关于AToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmAbout newFrm = new frmAbout();
            newFrm.ShowDialog();
 
(这个是我游戏的界面)


namespace MySnake
{
    public partial class frmSettings : Form
    {
        private IList<Point> objPointList;
        private Pen objPenEdge;
        private SolidBrush objSBBody;
        private Graphics g;

        public frmSettings()
        {
            InitializeComponent();
        }

        private void txtUp_KeyDown(object sender, KeyEventArgs e)
        {
            ((TextBox)sender).Text = e.KeyData.ToString();
        }

        private void frmSettings_Load(object sender, EventArgs e)
        {
            objPointList = new List<Point>();

            for (int i = 5; i < 11; i++)
            {
                objPointList.Add(new Point(i, 2));
            }

            try
            {
                Config objConfig = new Config();
                string strMaxLength = objConfig.GetConfigValue("MaxLength");
                string strSpeed = objConfig.GetConfigValue("Speed");
                string strUp = objConfig.GetConfigValue("Up");
                string strDown = objConfig.GetConfigValue("Down");
                string strLeft = objConfig.GetConfigValue("Left");
                string strRight = objConfig.GetConfigValue("Right");

                txtMaxLength.Text = strMaxLength;
            }
            catch
            {
                MessageBox.Show("加载配置文件失败!");
            }
        }


        private void btnClose_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            MessageBox.Show("修改设置成功!新设置将在游戏开始是生效!");
        }
    }
}
 
(这个是游戏设置的界面)

搜索更多相关主题的帖子: 中文 注解 
2010-06-10 20:52
快速回复:大家帮我用中文注解一下啊,谢谢
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.026314 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved