autocontrol

This commit is contained in:
unknown
2010-08-30 11:03:21 +04:00
parent 183d1a45b9
commit 13f8040f4e
9 changed files with 392 additions and 274 deletions

View File

@@ -101,11 +101,16 @@ void Splashes::update()
if (distance2(spl.pos, spl.destination) < src.speed*src.speed)
{
deadIndexes.push_back(spl.id);
curDead = spl.id;
deadIndexes.push_back(spl.id);
curDead = spl.id;
}
if (curDead < 0)
{
if (src.autoControl)
{
if (gameData->curAliens.contains(spl.AlienId))
spl.destination = gameData->curAliens.value(spl.AlienId).pos;
}
arctg = std::atan2(spl.pos.x() - spl.destination.x(),spl.pos.y() - spl.destination.y());
//if (tmpdy < 0) arctg=arctg+M_PI;
angl = 180.0f*(-arctg)/M_PI;
@@ -113,13 +118,13 @@ void Splashes::update()
spl.angle = angl;
spl.pos.setX(spl.pos.x()
-src.speed*std::sin(arctg));
-src.speed*std::sin(arctg));
spl.pos.setY(spl.pos.y()
-src.speed*std::cos(arctg));
-src.speed*std::cos(arctg));
}
// TODO: calculate new angle and pos....
// TODO: smooth splash rotate
// TODO: activate trigger and more...
gameData->curSplashes.insert(spl.id,spl);
}