我的星空我的路吧 关注:2贴子:245
  • 0回复贴,共1
bool HelloWorld::doTop()
{
for (int x = 0; x < 4; x++)
{
for (int y = 3; y >=0; y--)
{
for (int aftery = y-1; aftery >=0; aftery--)
{
if (m_squarearray[x][y]->getNumber()==0)
{
m_squarearray[x][y]->setNumber(m_squarearray[x][aftery]->getNumber());
m_squarearray[x][aftery]->setNumber(0);
}
else if (m_squarearray[x][aftery]->getNumber()==m_squarearray[x][y]->getNumber())
{
bool isAdd=false;
for (int temp = aftery+1; temp < y; temp++)
{
if (m_squarearray[x][temp]->getNumber()!=0)
{
isAdd=true;
break;
}
}
if (isAdd)
{
continue;
}
m_TotalScore+=m_squarearray[x][y]->getNumber()*2;
m_squarearray[x][y]->setNumber(m_squarearray[x][y]->getNumber()*2);
m_squarearray[x][aftery]->setNumber(0);
break;
}
}
}
}
return true;
}


IP属地:浙江1楼2014-12-14 16:12回复