Updated the web pages
[ghostsoverboard] / octopus.cpp
1 /**************************************************************************
2         Ghosts Overboard - a game for Maemo 5
3
4         Copyright (C) 2011  Heli Hyvättinen
5
6         This file is part of Ghosts Overboard
7
8         Ghosts Overboard is free software: you can redistribute it and/or modify
9         it under the terms of the GNU General Public License as published by
10         the Free Software Foundation, either version 2 of the License, or
11         (at your option) any later version.
12
13         This program is distributed in the hope that it will be useful,
14         but WITHOUT ANY WARRANTY; without even the implied warranty of
15         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16         GNU General Public License for more details.
17
18         You should have received a copy of the GNU General Public License
19         along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
21 **************************************************************************/
22
23 #include "octopus.h"
24
25 Octopus::Octopus(QPixmap pixmap, int speed, QGraphicsItem *parent) :
26     TimerControlledGraphicsPixmapObject(pixmap,speed,parent)
27 {
28 }
29
30 bool Octopus::handleCollisions()
31 {
32
33     QList<QGraphicsItem*>  collidesList = collidingItems();
34     if (collidesList.isEmpty())
35             return true; //retain new position
36
37     else
38     {
39         //change direction if hit anything
40         changeDirection();
41         //the game allows only one object to saty at given spot, so just check the firs one
42         if (collidesList.at(0)->data(0) == "ship")
43         {
44             emit droppingGhosts();
45         }
46         return false; //go back to old position
47     }
48 }