Class restructure for octopus
[ghostsoverboard] / octopus.cpp
1 #include "octopus.h"
2
3 Octopus::Octopus(QPixmap pixmap, int speed, QGraphicsItem *parent) :
4     TimerControlledGraphicsPixmapObject(pixmap,speed,parent)
5 {
6 }
7
8 bool Octopus::handleCollisions()
9 {
10
11     QList<QGraphicsItem*>  collidesList = collidingItems();
12     if (collidesList.isEmpty())
13             return true; //retain new position
14
15     else
16     {
17         //change direction if hit anything
18         changeDirection();
19         //the game allows only one object to saty at given spot, so just check the firs one
20         if (collidesList.at(0)->data(0) == "ship")
21         {
22             emit droppingGhosts();
23         }
24         return false; //go back to old position
25     }
26 }