From ce48af53646cd9e7ec762fc1ac176b3aa620b11d Mon Sep 17 00:00:00 2001 From: manuel Date: Thu, 5 May 2011 00:57:07 +0200 Subject: - refactorized the whole project and made a few subprojects - replaced tcp with enet - added connect dialog - some smaller bugfixes --- pacman-c++/common/actor.h | 81 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 pacman-c++/common/actor.h (limited to 'pacman-c++/common/actor.h') 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 @@ +#ifndef ACTOR_H +#define ACTOR_H + +#include "gameentity.h" +#include "constants.h" +#include "audio.h" +#include +#include +#include + +class Actor + : public GameEntity +{ +Q_OBJECT + +public: + enum Movement + { + None = 0, + Left, + Right, + Up, + Down, + }; + + enum + { + Type = UserType + Transmission::pacman + }; + + Actor(Color::Color color, bool local = false, QGraphicsItem *parent = 0); + virtual ~Actor() + {}; + + PixmapItem &icon(); + const QString iconStr(); + Movement direction(); + void setDirection(Movement direction); + void reset(); + bool hadReset(); + bool isLocal(); + void move(Movement direction); + void move(QPoint newpos); + bool isMoving(); + void die(); + void eatingFruit(); + void eatingPacman(); + void startEating(); + void stopEating(); + bool canEat(Actor *other, const QList &order); + virtual void onDie(Actor *); + + unsigned int getRoundPoints(); + unsigned int getGamePoints(); + void addRoundPoints(unsigned int amount); + void finishRound(bool died = false); + + static QPoint movementToPoint(const Movement direction); + +private: + void moveByServer(Movement direction); + QSequentialAnimationGroup *setupEatingAnimation(Actor::Movement direction); + +private: + QPixmap m_pix; + Movement m_direction; + PixmapItem m_icon; + bool m_local; + bool m_reset; + GaplessAudioPlayer *m_wakaPlayer; + + unsigned int m_roundPoints; + unsigned int m_gamePoints; + + QList m_images; + QList m_eating; + QParallelAnimationGroup *m_moving; + QSequentialAnimationGroup *m_dieing; +}; + +#endif // ACTOR_H -- cgit v1.2.3