Menu items in correct places again
[ghostsoverboard] / timercontrolledgraphicspixmapobject.h
1 /**************************************************************************
2         Ghosts Overboard - a game for Maemo 5
3
4         Copyright (C) 2011  Heli Hyvättinen
5
6         This file is part of Ghosts Overboard
7
8         Ghosts Overboard is free software: you can redistribute it and/or modify
9         it under the terms of the GNU General Public License as published by
10         the Free Software Foundation, either version 2 of the License, or
11         (at your option) any later version.
12
13         This program is distributed in the hope that it will be useful,
14         but WITHOUT ANY WARRANTY; without even the implied warranty of
15         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16         GNU General Public License for more details.
17
18         You should have received a copy of the GNU General Public License
19         along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
21 **************************************************************************/
22
23 #ifndef TIMERCONTROLLEDGRAPHICSPIXMAPOBJECT_H
24 #define TIMERCONTROLLEDGRAPHICSPIXMAPOBJECT_H
25
26 #include <QObject>
27 #include <QGraphicsPixmapItem>
28 #include <QTimer>
29
30 class TimerControlledGraphicsPixmapObject : public QObject, public QGraphicsPixmapItem
31 {
32     Q_OBJECT
33 public:
34     explicit TimerControlledGraphicsPixmapObject(QPixmap pixmap = QPixmap(), int speed = 1, QGraphicsItem *parent = 0);
35
36
37 signals:
38
39 public slots:
40
41     void startMoving();
42     void stopMoving();
43
44     /*! Intended to be used internally by connecting to a timer
45       */
46     void move();
47
48     /*! Sets the movement speed of the item
49       @param speed given in pixels per second
50       */
51     void setSpeed(int speed);
52
53
54  protected:
55
56     void changeDirection();
57
58     virtual bool handleCollisions();
59
60     QTimer timer_;
61
62     enum direction {N, NE, E, SE, S, SW, W, NW};
63
64     direction direction_;
65
66     bool stoppedBecauseInvalidTime_;
67
68
69 };
70
71 #endif // TIMERCONTROLLEDGRAPHICSPIXMAPOBJECT_H