以下是引用yhlvht在2013-6-12 20:56:56的发言:
private void StartGame()
{
Dsnake = new Ds(Putfood);
this.Invoke(Dsnake, null);
while (true)
{
Thread.Sleep(speed);
if (sb.HasEatfood(temppoint))
{
Dsnake = new Ds(Killfood);
this.Invoke(Dsnake, null);
Dsnake = new Ds(Putfood);
this.Invoke(Dsnake, null);
}
Dsnake = new Ds(Movesnakes);
this.Invoke(Dsnake, null);
if (isGameover())
{
MessageBox.Show("GAME OVER");
try
{
thread.Abort();
}
catch
{
}
}
}
//if(sb.HasEatfood(temppoint))
//{
// Dsnake = new Ds(Killfood);
// this.Invoke(Dsnake, null);
// Dsnake = new Ds(Putfood);
// this.Invoke(Dsnake, null);
//}
//Dsnake = new Ds(Movesnakes);
//this.Invoke(Dsnake, null);
}
form1中的StartGame方法,如上代码,将注释代码放入while中即可
不过除此以外,程序还有不少bug,但应该都是些小问题
我也是这样调回来的,我发现它没跳进那里我仔细看了下发现做的时候{}放错了
现在关闭窗口我不会求指导 if (dr == DialogResult.OK)
{
求补充
}
我本来打的是this.close()但是它跳到disopse()里面我不会弄求教下!