running=true;
while(running)
{
try
{
Thread.sleep(timeInterval);
}catch(Exception e)
{
break;
}
if(!paused)
{
if(moveOn())// 未结束
{
gs.repaint();
}
else//游戏结束
{
JOptionPane.showMessageDialog(null,"GAME OVER",
"Game Over",JOptionPane.INFORMATION_MESSAGE);
break;
}
}
}
running=false;
}
//----------------------------------------------------------------------
//createFood():生成食物及放置地点
//----------------------------------------------------------------------
private Node createFood()
延伸阅读
文章来源于领测软件测试网 https://www.ltesting.net/