基本信息
源码名称:C# 贪吃蛇小程序 游戏源码
源码大小:0.05M
文件格式:.rar
开发语言:C#
更新时间:2017-09-12
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300

本次赞助数额为: 2 元 
   源码介绍
贪吃蛇小游戏

 /// <summary>
        /// 移动贪吃蛇
        /// </summary>
        /// <param n="int">标识,判断的移动的方向</param>
        public void SnakeMove(int n)
        {
            Point tem_Point = new Point(-1, -1);//定义坐标结构
            switch (n)
            {
                case 0://右移
                    {
                        tem_Point.X = ((Point)List[0]).X Condyle;//蛇头向右移
                        tem_Point.Y = ((Point)List[0]).Y;
                        break;
                    }
                case 1://左移
                    {
                        tem_Point.X = ((Point)List[0]).X - Condyle;//蛇头向左移
                        tem_Point.Y = ((Point)List[0]).Y;
                        break;
                    }
                case 2://上移
                    {
                        tem_Point.Y = ((Point)List[0]).Y - Condyle;//蛇头向上移
                        tem_Point.X = ((Point)List[0]).X;
                        break;
                    }
                case 3://下移
                    {
                        tem_Point.Y = ((Point)List[0]).Y Condyle;//蛇头向下移
                        tem_Point.X = ((Point)List[0]).X;
                        break;
                    }
            }
            BuildFood();//生成食物
            if (!EstimateMove(tem_Point))//如果没有向相反的方向移动
            {
                Aspect = n;//改变贪吃蛇的移动方向
                if (!GameAborted(tem_Point))//如果游戏没有结束
                {
                    ProtractSnake(tem_Point);//重新绘制蛇身
                    EatFood();//吃食
                }
                g.FillRectangle(SolidF, Food.X 1, Food.Y 1, Condyle - 1, Condyle - 1);//绘制食物
            }
        }

        /// <summary>
        /// 吃食
        /// </summary>
        public void EatFood()
        {
            if (((Point)List[0]) == Food)//如果蛇头吃到了食物
            {
                List.Add(List[List.Count - 1]);//在蛇的尾部添加蛇身
                ifFood = false;//没有食物
                BuildFood();//生成食物
                label.Text = Convert.ToString(Convert.ToInt32(label.Text) 5);//显示当前分数
            }
        }