Octopus speed given can now be zero or less
authorHeli Hyvättinen <heli.hyvattinen@kymp.net>
Thu, 23 Jun 2011 19:14:25 +0000 (22:14 +0300)
committerHeli Hyvättinen <heli.hyvattinen@kymp.net>
Thu, 23 Jun 2011 19:14:25 +0000 (22:14 +0300)
If it is the octopus won't move.

timercontrolledgraphicspixmapobject.cpp
timercontrolledgraphicspixmapobject.h

index 56913f6..c9896c1 100644 (file)
@@ -35,7 +35,8 @@ TimerControlledGraphicsPixmapObject::TimerControlledGraphicsPixmapObject(QPixmap
 
 void TimerControlledGraphicsPixmapObject::startMoving()
 {
-    timer_.start();
+    if (!stoppedBecauseInvalidTime_)
+        timer_.start();
 }
 
 void TimerControlledGraphicsPixmapObject::stopMoving()
@@ -45,9 +46,16 @@ 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;
 }
 
+
 void TimerControlledGraphicsPixmapObject::move()
 {
 
index f121bf1..b4919fb 100644 (file)
@@ -63,6 +63,8 @@ public slots:
 
     direction direction_;
 
+    bool stoppedBecauseInvalidTime_;
+
 
 };