1 /**************************************************************************
2 Ghosts Overboard - a game for Maemo 5
4 Copyright (C) 2011 Heli Hyvättinen
6 This file is part of Ghosts Overboard
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.
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.
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/>.
21 **************************************************************************/
26 #include <QDBusMessage>
27 #include <QDBusConnection>
30 Ship::Ship(QList<QPixmap> pixmapList, QGraphicsItem *parent) :
31 OrientationControlledGraphicsPixmapObject(pixmapList.at(0),parent)
33 shipImages_ = pixmapList;
35 vibrationActive_ = false;
38 bool Ship::handleCollisions()
40 QList<QGraphicsItem*> collidesList = collidingItems();
42 if (collidesList.isEmpty())
47 //since the game logic does not leave items to collide with each other we can take just the topmost one
48 //and trust it is the only one
49 QString type = collidesList.at(0)->data(0).toString();
52 if (type == "rock" || type == "octopus")
54 // drop all ghosts when hitting an obstacle
58 //go back to old position
63 else if (type == "ghost")
68 // qDebug() << ghostsAboard_ << " ghosts aboard";
70 emit pickingGhost(collidesList.at(0));
78 return true; //execution can never reach here, this is just to stop the compiler from complaining
81 void Ship::updateShipImage()
83 int index = qBound(0,ghostsAboard_,shipImages_.length()-1);
84 setPixmap(shipImages_.at(index));
87 void Ship::dropAllGhosts()
90 emit droppingGhosts(ghostsAboard_);
98 QDBusMessage message = QDBusMessage::createMethodCall("com.nokia.mce","/com/nokia/mce/request","com.nokia.mce.request","req_vibrator_pattern_activate");
100 QList<QVariant> arguments;
102 arguments.append("PatternChatAndEmail");
104 message.setArguments(arguments);
106 message = QDBusConnection::systemBus().call(message);
108 //qDebug() << message;
112 void Ship::setVibrationActivate(bool on)
114 vibrationActive_ = on;