calculate tower angle

switch autocontrol for splashes
This commit is contained in:
root
2010-08-30 16:40:40 +04:00
parent 13f8040f4e
commit 3e6460abd4
5 changed files with 272 additions and 141 deletions

View File

@@ -57,7 +57,7 @@ void Towers::update()
if ((*i).build < stw.buildTime)
{
(*i).build++;
qDebug() << "building tower ..." << (*i).build;
//qDebug() << "building tower ..." << (*i).build;
} else {
if (!(gameData->curAliens.contains((*i).aim)))
(*i).aim = -1;
@@ -81,6 +81,13 @@ void Towers::update()
//else (*i).aim = -1;
}
}
// TODO: calculate tower angl
if ((*i).aim > 0)
{
float arctg = std::atan2((*i).pos.x() - gameData->curAliens.value((*i).aim).pos.x(),(*i).pos.y() - gameData->curAliens.value((*i).aim).pos.y());
//if (tmpdy < 0) arctg=arctg+M_PI;
(*i).angle = 180.0f*(-arctg)/M_PI;
}
// TODO: smooth rotate tower to aim
if ((*i).reload < stw.reload)
(*i).reload++;
@@ -90,10 +97,10 @@ void Towers::update()
{
(*i).reload = 0;
emit shot(stw.splashes.at(0), 0, (*i));
qDebug("shot!");
//qDebug("shot!");
}
}
}
qDebug() << "aim=" << (*i).aim;
//qDebug() << "aim=" << (*i).aim;
}
}