| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 794 人关注过本帖
标题:大家可否提示一下解题思路啊?
取消只看楼主 加入收藏
zsk503
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2007-5-17
收藏
 问题点数:0 回复次数:0 
大家可否提示一下解题思路啊?
我下了一个贪食蛇的源程序,问题在于它是怎么动的?这一点看不明白,主要代码:
bool flag = true;     
int fangx = 2;  // fangx 代表的是什么???不懂
 Point dou = new Point()
LinkedList<Point> ll = new LinkedList<Point>()
void F_Move()

        {

            Point first = ll.First.Value;//ll表示双向链表
            switch (fangx)
            {
                case 0:
                    {
                        if (flag)
                        {
                            if (first.Y == 0)//为什么坐标是这样?不懂

                            {
                                first.Y = 40;
                            }
                        }
                        ll.AddFirst(new Point(first.X, --first.Y ));
                        break;
                    }
                case 1:
                    {
                        if (flag)
                        {
                            if (first.X == 0)//为什么坐标是这样?不懂
                            {
                                first.X = 40;
                            }
                        }
                        ll.AddFirst(new Point(--first.X, first.Y));
                        break;
                    }
                case 2:
                    {
                        if (flag)
                        {
                            if (first.X == 39)
                            {
                                first.X = -1;
                            }
                        }
                        ll.AddFirst(new Point(++first.X, first.Y));//不懂?????
                        break;
                    }
                case 3:
                    {
                        if (flag)
                        {
                            if (first.Y == 39)//不懂??
                            {
                                first.Y = -1;
                            }
                        }
                        ll.AddFirst(new Point(first.X, ++first.Y ));
                        break;
                    }
            }
            if (first.Equals(dou))
            {
                F_score();//获得分数
                dou = F_getdou();
            }
            else
            {
                ll.RemoveLast();
            }
            int i = 0;
            foreach (Point p in ll)
            {
                if (p.Equals(first))
                {
                    i++;
                }
            }
            if (first.X > 39 || first.X < 0 || first.Y > 39 || first.Y < 0 || i > 1)//不懂???
            {
                F_Over();//结束
                return;
            }
            F_paint();
        }

      Point  F_getdou()
        {
            int i = new Random().Next(1690);
            return  new Point(i / 40, i % 40);
        }
//
搜索更多相关主题的帖子: 思路 解题 提示 
2008-10-07 23:37
快速回复:大家可否提示一下解题思路啊?
数据加载中...
 
   



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

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