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

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

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

  namespace WindowsFormsApplication2
    {
        class SnakeBlock : Block
        {
            private bool isHead;
            public bool IsHead
            {
                get
                {
                    return isHead;
                }
            }
            public SnakeBlock(int x, int y, Color _color, bool _isHead)
            {
                origion = new Point(x, y);
                color = _color;
                isHead = _isHead;
            }
            public void ChangeHeadToBody()
            {
                if (isHead)
                    isHead = false;
            }
            public void Display(Graphics g, Direction direction)
            {
                base.Display(g);
                if (isHead)
                {
                    //绘制蛇眼
                    SolidBrush brush = new SolidBrush(Color.Brown);
                    switch (direction)
                    {
                        case Direction.Up:
                        case Direction.Down:
                            g.FillRectangle(brush, origion.X WIDTH / 4, origion.Y
                            HEIGHT / 2, 2, 2);
                            g.FillRectangle(brush, origion.X WIDTH / 4 * 3, origion.Y
                            HEIGHT / 2, 2, 2);
                            break;
                        case Direction.Left:
                        case Direction.Right:
                            g.FillRectangle(brush, origion.X WIDTH / 2, origion.Y
                            HEIGHT / 4, 2, 2);
                            g.FillRectangle(brush, origion.X WIDTH / 2, origion.Y
                            HEIGHT / 4 * 3, 2, 2);
                            break;
                    }
                }
            }
        }
    }