calculate tower angle
switch autocontrol for splashes
This commit is contained in:
13
towers.cpp
13
towers.cpp
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user