From: Heli Hyvättinen Date: Thu, 23 Jun 2011 19:14:25 +0000 (+0300) Subject: Octopus speed given can now be zero or less X-Git-Tag: v.0.2.0~15 X-Git-Url: http://vcs.maemo.org/git/?a=commitdiff_plain;ds=sidebyside;h=fc5de9a3bac1a47d281a12a6f5a6e82c3c6c771b;p=ghostsoverboard Octopus speed given can now be zero or less If it is the octopus won't move. --- diff --git a/timercontrolledgraphicspixmapobject.cpp b/timercontrolledgraphicspixmapobject.cpp index 56913f6..c9896c1 100644 --- a/timercontrolledgraphicspixmapobject.cpp +++ b/timercontrolledgraphicspixmapobject.cpp @@ -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() { diff --git a/timercontrolledgraphicspixmapobject.h b/timercontrolledgraphicspixmapobject.h index f121bf1..b4919fb 100644 --- a/timercontrolledgraphicspixmapobject.h +++ b/timercontrolledgraphicspixmapobject.h @@ -63,6 +63,8 @@ public slots: direction direction_; + bool stoppedBecauseInvalidTime_; + };