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
32 //go back to old position
37 else if (type == "ghost")
42 // qDebug() << ghostsAboard_ << " ghosts aboard";
44 emit pickingGhost(collidesList.at(0));
52 return true; //execution can never reach here, this is just to stop the compiler from complaining
55 void Ship::updateShipImage()
57 int index = qBound(0,ghostsAboard_,shipImages_.length()-1);
58 setPixmap(shipImages_.at(index));
61 void Ship::dropAllGhosts()
64 emit droppingGhosts(ghostsAboard_);