diff options
Diffstat (limited to 'pacman-c++/common/actor.h')
| -rw-r--r-- | pacman-c++/common/actor.h | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/pacman-c++/common/actor.h b/pacman-c++/common/actor.h new file mode 100644 index 0000000..c30c62a --- /dev/null +++ b/pacman-c++/common/actor.h | |||
| @@ -0,0 +1,81 @@ | |||
| 1 | #ifndef ACTOR_H | ||
| 2 | #define ACTOR_H | ||
| 3 | |||
| 4 | #include "gameentity.h" | ||
| 5 | #include "constants.h" | ||
| 6 | #include "audio.h" | ||
| 7 | #include <QtCore/QSequentialAnimationGroup> | ||
| 8 | #include <QtCore/QParallelAnimationGroup> | ||
| 9 | #include <QList> | ||
| 10 | |||
| 11 | class Actor | ||
| 12 | : public GameEntity | ||
| 13 | { | ||
| 14 | Q_OBJECT | ||
| 15 | |||
| 16 | public: | ||
| 17 | enum Movement | ||
| 18 | { | ||
| 19 | None = 0, | ||
| 20 | Left, | ||
| 21 | Right, | ||
| 22 | Up, | ||
| 23 | Down, | ||
| 24 | }; | ||
| 25 | |||
| 26 | enum | ||
| 27 | { | ||
| 28 | Type = UserType + Transmission::pacman | ||
| 29 | }; | ||
| 30 | |||
| 31 | Actor(Color::Color color, bool local = false, QGraphicsItem *parent = 0); | ||
| 32 | virtual ~Actor() | ||
| 33 | {}; | ||
| 34 | |||
| 35 | PixmapItem &icon(); | ||
| 36 | const QString iconStr(); | ||
| 37 | Movement direction(); | ||
| 38 | void setDirection(Movement direction); | ||
| 39 | void reset(); | ||
| 40 | bool hadReset(); | ||
| 41 | bool isLocal(); | ||
| 42 | void move(Movement direction); | ||
| 43 | void move(QPoint newpos); | ||
| 44 | bool isMoving(); | ||
| 45 | void die(); | ||
| 46 | void eatingFruit(); | ||
| 47 | void eatingPacman(); | ||
| 48 | void startEating(); | ||
| 49 | void stopEating(); | ||
| 50 | bool canEat(Actor *other, const QList<Color::Color> &order); | ||
| 51 | virtual void onDie(Actor *); | ||
| 52 | |||
| 53 | unsigned int getRoundPoints(); | ||
| 54 | unsigned int getGamePoints(); | ||
| 55 | void addRoundPoints(unsigned int amount); | ||
| 56 | void finishRound(bool died = false); | ||
| 57 | |||
| 58 | static QPoint movementToPoint(const Movement direction); | ||
| 59 | |||
| 60 | private: | ||
| 61 | void moveByServer(Movement direction); | ||
| 62 | QSequentialAnimationGroup *setupEatingAnimation(Actor::Movement direction); | ||
| 63 | |||
| 64 | private: | ||
| 65 | QPixmap m_pix; | ||
| 66 | Movement m_direction; | ||
| 67 | PixmapItem m_icon; | ||
| 68 | bool m_local; | ||
| 69 | bool m_reset; | ||
| 70 | GaplessAudioPlayer *m_wakaPlayer; | ||
| 71 | |||
| 72 | unsigned int m_roundPoints; | ||
| 73 | unsigned int m_gamePoints; | ||
| 74 | |||
| 75 | QList<PixmapItem *> m_images; | ||
| 76 | QList<QSequentialAnimationGroup *> m_eating; | ||
| 77 | QParallelAnimationGroup *m_moving; | ||
| 78 | QSequentialAnimationGroup *m_dieing; | ||
| 79 | }; | ||
| 80 | |||
| 81 | #endif // ACTOR_H | ||
