Keeps screen lit and pauses when app is backgrounded
[ghostsoverboard] / orientationcontrolledgraphicspixmapobject.cpp
index 5b3b4b1..23ccf0b 100644 (file)
@@ -48,6 +48,9 @@ void OrientationControlledGraphicsPixmapObject::readRotationSensor()
 
  //   qDebug() << deltax << " " << deltay;
 
+    int oldx = x();
+    int oldy = y();
+
     int newx = x() + deltax/15;
     int newy = y() + deltay/15;
 
@@ -58,14 +61,20 @@ void OrientationControlledGraphicsPixmapObject::readRotationSensor()
     setX(qBound(sceneRectangle.left(),newx,sceneRectangle.right()-pixmap().width()));
     setY(qBound(sceneRectangle.top(),newy,sceneRectangle.bottom()-pixmap().height()));
 
-}
 
+    //handle collisions and move back to the original position if false returned
 
-void OrientationControlledGraphicsPixmapObject::setBoundaries(QRectF boundaryrect)
-{
-    boundaryrect_ = boundaryrect;
+    if (handleCollisions() == false)
+    {
+        setX(oldx);
+        setY(oldy);
+    }
 
 }
 
 
+bool OrientationControlledGraphicsPixmapObject::handleCollisions()
+{
+    return true;
+}