大家可否提示一下解题思路啊?
我下了一个贪食蛇的源程序,问题在于它是怎么动的?这一点看不明白,主要代码: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);
}
//