+
+
+
+ //spread the octopuses
+
+
+ for (int i=0; i < octopuses; i++)
+ {
+ QPointF * pPosition = findRandomFreeSlot();
+
+ //If there was no room no point to continue
+ if (pPosition == NULL)
+ break;
+
+ QPixmap octopusPixmap (":/pix/tursas.png");
+ TimerControlledTursas * pOctopus = new TimerControlledTursas (octopusPixmap,100);
+ pOctopus->setData(0,"octopus");
+ pOctopus->setPos(*pPosition);
+ addItem(pOctopus);
+ pOctopus->startMoving();
+ delete pPosition;
+
+ }
+
+
+ //place the ship
+
+ QPointF * pPosition = findRandomFreeSlot();
+ if (pPosition == NULL)
+ {
+ // Game cannot begin without a free position for ship, so give an error message and return
+
+ QMessageBox::critical(NULL,"Error! Too many objects on screen","No free space to place the ship. The game cannot start. Please choose another level.");
+ return;
+ }
+
+ QList<QPixmap> shipImages;
+ shipImages.append(QPixmap(":/pix/laiva.png"));
+ shipImages.append(QPixmap(":/pix/laiva_1aave.png"));
+ shipImages.append(QPixmap(":/pix/laiva_2aave.png"));
+ shipImages.append(QPixmap(":/pix/laiva_3aave.png"));
+ shipImages.append(QPixmap(":/pix/laiva_4aave.png"));
+ shipImages.append(QPixmap(":/pix/laiva_5aave.png"));
+ shipImages.append(QPixmap(":/pix/laiva_6aave.png"));
+ shipImages.append(QPixmap(":/pix/laiva_7aave.png"));
+ shipImages.append(QPixmap(":/pix/laiva_8aave.png"));
+ shipImages.append(QPixmap(":/pix/laiva_9aave.png"));
+ shipImages.append(QPixmap(":/pix/laiva_10aave.png"));
+
+ Ship * pShip = new Ship (shipImages);
+ pShip->setData(0,"ship");
+ pShip->setPos(*pPosition);
+ addItem(pShip);
+ connect(pShip,SIGNAL(pickingGhost(QGraphicsItem*)),this, SLOT(removeGhost(QGraphicsItem*)) );
+ connect(pShip,SIGNAL(droppingGhosts(int)),this,SLOT(ghostsDropped(int)));
+ pShip->startMoving();
+ delete pPosition;