#-------------------------------------------------
QT += core gui
+QT += dbus
TARGET = ghostsoverboard
TEMPLATE = app
connect(pRestartLevelAction,SIGNAL(triggered()),this,SLOT(restartLevel()));
menuBar()->addAction(pRestartLevelAction);
+ QAction * pVibrateAction = new QAction(tr("Vibration effects"),this);
+ pVibrateAction->setCheckable(true);
+ addAction(pVibrateAction);
+ connect(pVibrateAction,SIGNAL(triggered(bool)),pScene_,SLOT(vibrationActivate(bool)));
+ menuBar()->addAction(pVibrateAction);
+
QAction * pAboutAction = new QAction(tr("About"),this);
addAction(pAboutAction);
currentLevel_ = 0;
+
//the boundaries of the scene are set to match the size of the view window, which is not
//available in the constructor --> timer needed
QTimer::singleShot(100,this,SLOT(initializeBoundaries()));
void restartGame();
+
private:
SeaScene * pScene_;
QList<Level> levelList_;
int currentLevel_;
+
};
#endif // MAINWINDOW_H
addItem(pShip);
connect(pShip,SIGNAL(pickingGhost(QGraphicsItem*)),this, SLOT(removeGhost(QGraphicsItem*)) );
connect(pShip,SIGNAL(droppingGhosts(int)),this,SLOT(ghostsDropped(int)));
+ connect(this,SIGNAL(vibrationActivated(bool)),pShip,SLOT(setVibrationActivate(bool)));
pShip->startMoving();
movingItems_.append(pShip);
connect(this,SIGNAL(pauseOn()),pShip,SLOT(stopMoving()));
screenLitKeeper_.keepScreenLit(false);
}
}
+
+void SeaScene::vibrationActivate(bool on)
+{
+ emit vibrationActivated(on);
+}
void allGhostsPicked();
void pauseOn();
void pauseOff();
+ void vibrationActivated(bool on);
public slots:
void pause (bool paused);
+ void vibrationActivate(bool);
+
protected:
/*! Gives a pointer to a random position if a free one is found. Otherwise returns NULL.
#include "ship.h"
#include <QDebug>
+#include <QDBusMessage>
+#include <QDBusConnection>
+
Ship::Ship(QList<QPixmap> pixmapList, QGraphicsItem *parent) :
OrientationControlledGraphicsPixmapObject(pixmapList.at(0),parent)
{
shipImages_ = pixmapList;
ghostsAboard_ = 0;
-
+ vibrationActive_ = false;
}
bool Ship::handleCollisions()
emit droppingGhosts(ghostsAboard_);
ghostsAboard_ = 0;
updateShipImage();
+
+ //vibrate
+
+ if (vibrationActive_)
+ {
+ QDBusMessage message = QDBusMessage::createMethodCall("com.nokia.mce","/com/nokia/mce/request","com.nokia.mce.request","req_vibrator_pattern_activate");
+
+ QList<QVariant> arguments;
+
+ arguments.append("PatternChatAndEmail");
+
+ message.setArguments(arguments);
+
+ message = QDBusConnection::systemBus().call(message);
+
+ //qDebug() << message;
+ }
}
+void Ship::setVibrationActivate(bool on)
+{
+ vibrationActive_ = on;
+}
void dropAllGhosts();
+ void setVibrationActivate(bool on);
+
protected:
protected:
QList<QPixmap> shipImages_;
+ bool vibrationActive_;
+
};
QObject(), QGraphicsPixmapItem(pixmap, parent)
{
setSpeed(speed);
- direction_ = S;
+ changeDirection();
connect(&timer_,SIGNAL(timeout()),this,SLOT(move()));
}
void TimerControlledGraphicsPixmapObject::startMoving()
{
- timer_.start();
+ if (!stoppedBecauseInvalidTime_)
+ timer_.start();
}
void TimerControlledGraphicsPixmapObject::stopMoving()
void TimerControlledGraphicsPixmapObject::setSpeed(int speed)
{
- timer_.setInterval(1000/speed); //converts from pixels in second to milliseconds per pixel
+ if (speed >0)
+ {
+ timer_.setInterval(1000/speed); //converts from pixels in second to milliseconds per pixel
+ stoppedBecauseInvalidTime_ = false;
+ }
+ else
+ stoppedBecauseInvalidTime_ = true;
+ timer_.stop();
}
+
void TimerControlledGraphicsPixmapObject::move()
{
direction direction_;
+ bool stoppedBecauseInvalidTime_;
+
};