1 /**************************************************************************
2 Ghosts Overboard - a game for 'Meego 1.2 Harmattan'
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>
28 #include <QFeedbackHapticsEffect>
35 Ship::Ship(QList<QPixmap> pixmapList, QGraphicsItem *parent) :
36 OrientationControlledGraphicsPixmapObject(pixmapList.at(0),parent)
38 shipImages_ = pixmapList;
40 vibrationActive_ = false;
43 bool Ship::handleCollisions()
45 QList<QGraphicsItem*> collidesList = collidingItems();
47 if (collidesList.isEmpty())
52 //since the game logic does not leave items to collide with each other we can take just the topmost one
53 //and trust it is the only one
54 QString type = collidesList.at(0)->data(0).toString();
57 if (type == "rock" || type == "octopus")
59 // drop all ghosts when hitting an obstacle
63 //go back to old position
68 else if (type == "ghost")
73 // qDebug() << ghostsAboard_ << " ghosts aboard";
75 emit pickingGhost(collidesList.at(0));
83 return true; //execution can never reach here, this is just to stop the compiler from complaining
86 void Ship::updateShipImage()
88 int index = qBound(0,ghostsAboard_,shipImages_.length()-1);
89 setPixmap(shipImages_.at(index));
92 void Ship::dropAllGhosts()
95 emit droppingGhosts(ghostsAboard_);
101 if (vibrationActive_)
104 // This is for fremantle
105 // QDBusMessage message = QDBusMessage::createMethodCall("com.nokia.mce","/com/nokia/mce/request","com.nokia.mce.request","req_vibrator_pattern_activate");
107 // QList<QVariant> arguments;
109 // arguments.append("PatternChatAndEmail");
111 // message.setArguments(arguments);
113 // message = QDBusConnection::systemBus().call(message);
115 //qDebug() << message;
118 //This is for Harmattan
120 QFeedbackHapticsEffect vibrationEffect;
121 vibrationEffect.setDuration(1000);
122 vibrationEffect.setIntensity(1.0);
123 vibrationEffect.start();
128 void Ship::setVibrationActivate(bool on)
130 vibrationActive_ = on;