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/sceneholder.h | 74 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 pacman-c++/common/sceneholder.h (limited to 'pacman-c++/common/sceneholder.h') diff --git a/pacman-c++/common/sceneholder.h b/pacman-c++/common/sceneholder.h new file mode 100644 index 0000000..0872837 --- /dev/null +++ b/pacman-c++/common/sceneholder.h @@ -0,0 +1,74 @@ +#ifndef SCENEHOLDER_H +#define SCENEHOLDER_H + +#include "constants.h" +#include + +class GameEntity; +class Actor; + +class SceneHolder + : public QGraphicsScene +{ + Q_OBJECT + +public: + SceneHolder(QObject *parent = 0); + virtual ~SceneHolder() + {}; + void reset(); + unsigned int pointsLeft(); + void updateMap(const Transmission::map_t& map); + void updateMap(const Transmission::map_t& map, const unsigned int x, const unsigned int y); + void setColor(Color::Color color = Color::none); + Color::Color color(); + void setEatingOrder(QList &order); + QList &eatingOrder(); + void showEatingText(bool show = true); + void showWaitingForPlayers(bool show = true); + +signals: + void allPointsRemoved(); + +private slots: + void decrementPoints(); + +protected: + /* process items that got delayed by one tick */ + void processDelayedItems(); + /* data conversion */ + QPoint mapPositionToCoord(unsigned int x, unsigned int y); + QPoint mapPositionToCoord(QPoint point); + QPoint CoordToMapPosition(unsigned int x, unsigned int y); + QPoint CoordToMapPosition(QPoint point); + +protected: + /* map of all pixmap instances */ + QVector< QVector > visualMap; + + /* map of actors in order to keep track of those instances */ + QMap m_actors; + + /* items that got removed/has been eaten + * must be remove one tick later + */ + QList m_oldItems; + /* we need to store items that killed an actor too (e.g. colored blocks) */ + QMap m_death; + + /* my local color */ + Color::Color m_color; + + /* a actor can only eat his upper neighbour + * the order of the neighbours is determined by the colors order (sent from server) + * please note that !pl1.canEat(pl2, ...) doesn't necessarily mean that pl2 can eat pl1 + * order MUST be in this format: [col1, [col2 ... colN], col1] + */ + QList m_eatingorder; + + /* points left before round ends */ + unsigned int m_pointsLeft; + QGraphicsTextItem *m_overlayText; +}; + +#endif // SCENEHOLDER_H -- cgit v1.2.3