I think finished structures
and some changes in loading and changes in map class we have 2 TODO now
This commit is contained in:
24
aliens.cpp
24
aliens.cpp
@@ -17,31 +17,33 @@ void Aliens::AddAlien(int srcId)
|
||||
qCritical("ERROR out of aliens range");
|
||||
return;
|
||||
}
|
||||
Alien al = gameData->srcAliens.at(srcId);
|
||||
AlienType al;// = gameData->srcAliens.at(srcId);
|
||||
al.Id = nextId;
|
||||
al.finish = gameData->map->finishs.at(qrand()%gameData->map->finishs.size());
|
||||
qDebug()<<gameData->map->finishs.size()<<qrand()%gameData->map->finishs.size();
|
||||
al.pos = QPointF(gameData->map->starts.at(qrand()%gameData->map->starts.size()));
|
||||
al.src = srcId;
|
||||
al.finish = gameData->map->Finishs().at(qrand()%gameData->map->Finishs().size());
|
||||
al.pos = QPointF(gameData->map->Starts().at(qrand()%gameData->map->Starts().size()));
|
||||
al.path = gameData->map->CreatePath(al.pos.toPoint(),al.finish);
|
||||
al.pathIndex = 1;
|
||||
if (al.path.isEmpty()) qFatal("ERROR create path");
|
||||
qDebug() << al.path;
|
||||
al.health = gameData->srcAliens.at(srcId).health;
|
||||
al.speed = gameData->srcAliens.at(srcId).speed;
|
||||
al.imgType = gameData->srcAliens.at(srcId).imgType;
|
||||
//gameData->map->printMap();
|
||||
gameData->curAliens.insert(al.Id,al);
|
||||
nextId++;
|
||||
}
|
||||
|
||||
|
||||
void Aliens::retrace(bool *OK)
|
||||
void Aliens::retrace(bool * OK)
|
||||
{
|
||||
qDebug("re-trace!");
|
||||
gameData->map->removeAliensPath();
|
||||
for (int i=0; i<gameData->curAliens.size(); i++)
|
||||
{
|
||||
Alien al = gameData->curAliens.take(i);
|
||||
al.path = gameData->map->CreatePath(al.pos.toPoint(),al.finish);
|
||||
al.pathIndex = 1;
|
||||
if (al.path.isEmpty()) *OK = false;
|
||||
gameData->curAliens.values()[i].path = gameData->map->CreatePath(gameData->curAliens.values()[i].pos.toPoint(),gameData->curAliens.values()[i].finish);
|
||||
gameData->curAliens.values()[i].pathIndex = 1;
|
||||
if (gameData->curAliens.values()[i].path.isEmpty()) *OK = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +59,7 @@ void Aliens::update()
|
||||
QList <int> missIndex;
|
||||
for (int i=0; i<gameData->curAliens.size(); i++)
|
||||
{
|
||||
Alien al = gameData->curAliens.values().at(i);
|
||||
AlienType al = gameData->curAliens.values().at(i);
|
||||
//qDebug() << i;
|
||||
//if (al.health < 0) emit AlienKill();
|
||||
float tmpdx,tmpdy,angl,arctg = 0;
|
||||
@@ -101,7 +103,7 @@ void Aliens::update()
|
||||
al.pos.setY(al.pos.y()
|
||||
-al.speed*std::cos(arctg));
|
||||
//return true;
|
||||
gameData->curAliens[al.Id] = al;
|
||||
gameData->curAliens.insert(al.Id,al);
|
||||
}
|
||||
for (int j=0; j<missIndex.size(); j++)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user