Qctopuses now drop the ghosts when hitting the ship
[ghostsoverboard] / timercontrolledgraphicspixmapobject.h
1 #ifndef TIMERCONTROLLEDGRAPHICSPIXMAPOBJECT_H
2 #define TIMERCONTROLLEDGRAPHICSPIXMAPOBJECT_H
3
4 #include <QObject>
5 #include <QGraphicsPixmapItem>
6 #include <QTimer>
7
8 class TimerControlledGraphicsPixmapObject : public QObject, public QGraphicsPixmapItem
9 {
10     Q_OBJECT
11 public:
12     explicit TimerControlledGraphicsPixmapObject(QPixmap pixmap = QPixmap(), int speed = 1, QGraphicsItem *parent = 0);
13
14
15 signals:
16
17 public slots:
18
19     void startMoving();
20     void stopMoving();
21
22     /*! Intended to be used internally by connecting to a timer
23       */
24     void move();
25
26     /*! Sets the movement speed of the item
27       @param speed given in pixels per second
28       */
29     void setSpeed(int speed);
30
31
32  protected:
33
34     void changeDirection();
35
36     virtual bool handleCollisions();
37
38     QTimer timer_;
39
40     enum direction {N, NE, E, SE, S, SW, W, NW};
41
42     direction direction_;
43
44
45 };
46
47 #endif // TIMERCONTROLLEDGRAPHICSPIXMAPOBJECT_H