4 Ship::Ship(QList<QPixmap> pixmapList, QGraphicsItem *parent) :
5 OrientationControlledGraphicsPixmapObject(pixmapList.at(0),parent)
7 shipImages_ = pixmapList;
12 bool Ship::handleCollisions()
14 QList<QGraphicsItem*> collidesList = collidingItems();
16 if (collidesList.isEmpty())
21 //since the game logic does not leave items to collide with each other we can take just the topmost one
22 //and trust it is the only one
23 QString type = collidesList.at(0)->data(0).toString();
26 if (type == "rock" || type == "octopus")
28 // drop all ghosts when hitting an obstacle
29 emit droppingGhosts(ghostsAboard_);
36 else if (type == "ghost")
41 // qDebug() << ghostsAboard_ << " ghosts aboard";
43 emit pickingGhost(collidesList.at(0));
51 void Ship::updateShipImage()
53 int index = qBound(0,ghostsAboard_,shipImages_.length()-1);
54 setPixmap(shipImages_.at(index));