clear();
+ //empty the list of moving items
+
+ movingItems_.clear();
+
//empty the list of free slots
freeTiles_.clear();
{
QPointF * pPosition = findRandomFreeSlot();
+ qDebug() << "Found a place for a rock";
+
//If there was no room no point to continue
if (pPosition == NULL)
break;
void SeaScene::spreadGhosts(int ghosts)
{
+ qDebug() << "Preparing to spread ghosts";
+
//the octopuses and the ship may have moved from their original positions,
//so the list of free slots must be adjusted to exclude their current positions
foreach (QGraphicsItem* pItem, movingItems_)
{
- //TODO
+ if (pItem == NULL)
+ {
+ // qDebug() << "NULL item in movingItems_";
+ continue;
+ }
+
//round x and y down to fit the slot size
int x = pItem->x();
x = x/40;
x = x*40;
+
int y = pItem->y();
y = y/40;
y=y*40;
}
+
//spread ghosts in random free slots
for (int i=0; i < ghosts; i++)