--- a/MixedView/MixedView.pro Mon Oct 25 10:46:37 2010 -0700
+++ b/MixedView/MixedView.pro Tue Oct 26 09:48:36 2010 -0700
@@ -26,7 +26,7 @@
symbian {
TARGET.UID3 = 0xe4cef592
LIBS += -lcone -leikcore -lavkon
- TARGET.CAPABILITY += AllFiles LocalServices ReadUserData WriteUserData NetworkServices UserEnvironment Location ReadDeviceData
+ TARGET.CAPABILITY += LocalServices ReadUserData WriteUserData NetworkServices UserEnvironment Location ReadDeviceData
TARGET.EPOCSTACKSIZE = 0x14000
TARGET.EPOCHEAPSIZE = 0x020000 0x10000000
}
--- a/MixedView/mainwindow.cpp Mon Oct 25 10:46:37 2010 -0700
+++ b/MixedView/mainwindow.cpp Tue Oct 26 09:48:36 2010 -0700
@@ -18,7 +18,6 @@
this->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
ui->setupUi(this);
mPacState = 0;
- bIsMoving = true;
xAxis = yAxis = 0;
mLastPt.setX(0);
mLastPt.setY(0);
@@ -44,11 +43,17 @@
QGraphicsPixmapItem *backGround = mScene->addPixmap(mazeImage);
backGround->setPos(-140,-200);
+ mPacCollider = new QGraphicsEllipseItem(0, 0, 18, 18);
+ mPacCollider->setBrush(QBrush(Qt::transparent));
+ mScene->addItem(mPacCollider);
+
mPacman = new QGraphicsEllipseItem(0, 0, 18, 18);
mPacman->setBrush(QBrush(Qt::yellow));
mPacman->setSpanAngle(4500);
mScene->addItem(mPacman);
+
+
// lets place a pause button in the view
pauseButton = new QPushButton("Pause");
connect(pauseButton, SIGNAL(clicked()), this, SLOT(pause()));
@@ -60,7 +65,7 @@
ui->mainGraphicsView->show();
mPacman->setPos(20,-8);
-
+ mPacCollider->setPos(20, -8);
// declare our update timer
mUpdateTimer = new QTimer(this);
connect(mUpdateTimer, SIGNAL(timeout()), this, SLOT(updateGraphics()));
@@ -69,6 +74,7 @@
// connect the accelerometer to the readingChanged signal
connect(mAccelerometer, SIGNAL(readingChanged()), this, SLOT(updateReading()));
mNumHits = 1;
+
}
MainWindow::~MainWindow()
@@ -80,8 +86,7 @@
if (mPause)
return;
- if (!bIsMoving)
- return;
+
// update the pacman mouth state
// will eventually change this to a graphic
switch (mPacState) {
@@ -101,21 +106,29 @@
mPacState += 1;
if (mPacState == 2)
mPacState = 0;
+
}
void MainWindow::updateReading() {
if (mPause)
return;
- mNumHits = mPacman->collidingItems().count();
- if (mNumHits == 1)
- mLastPt = mPacman->pos();
+
+ checkCollisions();
xAxis = (xAxis + mAccelerometer->reading()->x()) / 2;
yAxis = (yAxis + mAccelerometer->reading()->y()) / 2;
- QPointF pt = mPacman->pos();
+}
+
+void MainWindow::checkCollisions() {
+
+ mNumHits = mPacCollider->collidingItems().count();
+ if (mNumHits == 2)
+ mLastPt = mPacCollider->pos();
+
+ QPointF pt = mPacCollider->pos();
pt.setX(pt.x()-xAxis);
- pt.setY(pt.y()+yAxis);
+ pt.setY(pt.y()+yAxis);
if (pt.x()<-103)
pt.setX(-103);
@@ -127,11 +140,15 @@
else if (pt.y()>145)
pt.setY(145);
- if (mNumHits == 1) {
- mPacman->setPos(pt);
+ if (mNumHits == 2) {
+ mPacCollider->setPos(pt);
+ // mPacman->setPos(pt);
}
- else
- mPacman->setPos(mLastPt);
+ else {
+ mPacCollider->setPos(mLastPt);
+
+ }
+ mPacman->setPos(mLastPt);
}
--- a/MixedView/mainwindow.h Mon Oct 25 10:46:37 2010 -0700
+++ b/MixedView/mainwindow.h Tue Oct 26 09:48:36 2010 -0700
@@ -29,10 +29,9 @@
private:
Ui::MainWindow *ui;
- QGraphicsEllipseItem *mPacman;
+ QGraphicsEllipseItem *mPacman, *mPacCollider;
QTimer *mUpdateTimer;
int mPacState;
- bool bIsMoving;
QAccelerometer *mAccelerometer;
qreal xAxis, yAxis;
QPointF mLastPt;
@@ -45,6 +44,7 @@
QAudioOutput* mAudio;
QFile file;
+
private slots:
void updateGraphics();
void updateReading();
@@ -53,6 +53,7 @@
private:
void setupBoundries();
+ void checkCollisions();
};
--- a/cards/qmlapplicationviewer/qmlapplicationviewer.h Mon Oct 25 10:46:37 2010 -0700
+++ b/cards/qmlapplicationviewer/qmlapplicationviewer.h Tue Oct 26 09:48:36 2010 -0700
@@ -1,28 +1,28 @@
// checksum 0x39ee version 0x10008
-#ifndef QMLAPPLICATIONVIEWER_H
-#define QMLAPPLICATIONVIEWER_H
-
-#include <QtDeclarative/QDeclarativeView>
-
-class QmlApplicationViewer : public QDeclarativeView
-{
-public:
- enum Orientation {
- LockPortrait,
- LockLandscape,
- Auto
- };
-
- QmlApplicationViewer(QWidget *parent = 0);
- virtual ~QmlApplicationViewer();
-
- void setMainQmlFile(const QString &file);
- void addImportPath(const QString &path);
- void setOrientation(Orientation orientation);
- void show();
-
-private:
- class QmlApplicationViewerPrivate *m_d;
-};
-
-#endif // QMLAPPLICATIONVIEWER_H
+#ifndef QMLAPPLICATIONVIEWER_H
+#define QMLAPPLICATIONVIEWER_H
+
+#include <QtDeclarative/QDeclarativeView>
+
+class QmlApplicationViewer : public QDeclarativeView
+{
+public:
+ enum Orientation {
+ LockPortrait,
+ LockLandscape,
+ Auto
+ };
+
+ QmlApplicationViewer(QWidget *parent = 0);
+ virtual ~QmlApplicationViewer();
+
+ void setMainQmlFile(const QString &file);
+ void addImportPath(const QString &path);
+ void setOrientation(Orientation orientation);
+ void show();
+
+private:
+ class QmlApplicationViewerPrivate *m_d;
+};
+
+#endif // QMLAPPLICATIONVIEWER_H