Ship can now pick ghosts
[ghostsoverboard] / ship.cpp
1 #include "ship.h"
2 #include <QDebug>
3
4 Ship::Ship(QPixmap pixmap, QGraphicsItem *parent) :
5     OrientationControlledGraphicsPixmapObject(pixmap,parent)
6 {
7     ghostsAboard_ = 0;
8
9 }
10
11 bool Ship::handleCollisions()
12 {
13     QList<QGraphicsItem*>  collidesList = collidingItems();
14
15     if (collidesList.isEmpty())
16         return true;
17
18     else
19     {
20         //since the game logic does not leave items to collide with each other we can take just the topmost one
21         //and trust it is the only one
22         QString type = collidesList.at(0)->data(0).toString();
23         qDebug() << type;
24
25         if (type == "rock" || type == "octopus")
26         {
27 //            dropGhosts();
28             return false;
29         }
30
31         else if (type == "ghost")
32         {
33             ghostsAboard_++;
34
35             qDebug() << ghostsAboard_ << " ghosts aboard";
36
37             emit pickingGhost(collidesList.at(0));
38
39             return true;
40         }
41
42     }
43 }