summaryrefslogtreecommitdiffstats
path: root/pacman-c++/common/sceneholder.h
diff options
context:
space:
mode:
authormanuel <manuel@mausz.at>2011-05-05 00:57:07 +0200
committermanuel <manuel@mausz.at>2011-05-05 00:57:07 +0200
commitce48af53646cd9e7ec762fc1ac176b3aa620b11d (patch)
treef8fbf2cae8c7d0cbac2696a8f4cf94410bfb4928 /pacman-c++/common/sceneholder.h
parente54ccad07e256ba877bd41d70bd358bd0085bd1e (diff)
downloadfoop-ce48af53646cd9e7ec762fc1ac176b3aa620b11d.tar.gz
foop-ce48af53646cd9e7ec762fc1ac176b3aa620b11d.tar.bz2
foop-ce48af53646cd9e7ec762fc1ac176b3aa620b11d.zip
- refactorized the whole project and made a few subprojects
- replaced tcp with enet - added connect dialog - some smaller bugfixes
Diffstat (limited to 'pacman-c++/common/sceneholder.h')
-rw-r--r--pacman-c++/common/sceneholder.h74
1 files changed, 74 insertions, 0 deletions
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 @@
1#ifndef SCENEHOLDER_H
2#define SCENEHOLDER_H
3
4#include "constants.h"
5#include <QtGui>
6
7class GameEntity;
8class Actor;
9
10class SceneHolder
11 : public QGraphicsScene
12{
13 Q_OBJECT
14
15public:
16 SceneHolder(QObject *parent = 0);
17 virtual ~SceneHolder()
18 {};
19 void reset();
20 unsigned int pointsLeft();
21 void updateMap(const Transmission::map_t& map);
22 void updateMap(const Transmission::map_t& map, const unsigned int x, const unsigned int y);
23 void setColor(Color::Color color = Color::none);
24 Color::Color color();
25 void setEatingOrder(QList<Color::Color> &order);
26 QList<Color::Color> &eatingOrder();
27 void showEatingText(bool show = true);
28 void showWaitingForPlayers(bool show = true);
29
30signals:
31 void allPointsRemoved();
32
33private slots:
34 void decrementPoints();
35
36protected:
37 /* process items that got delayed by one tick */
38 void processDelayedItems();
39 /* data conversion */
40 QPoint mapPositionToCoord(unsigned int x, unsigned int y);
41 QPoint mapPositionToCoord(QPoint point);
42 QPoint CoordToMapPosition(unsigned int x, unsigned int y);
43 QPoint CoordToMapPosition(QPoint point);
44
45protected:
46 /* map of all pixmap instances */
47 QVector< QVector<GameEntity *> > visualMap;
48
49 /* map of actors in order to keep track of those instances */
50 QMap<Color::Color, Actor *> m_actors;
51
52 /* items that got removed/has been eaten
53 * must be remove one tick later
54 */
55 QList<GameEntity *> m_oldItems;
56 /* we need to store items that killed an actor too (e.g. colored blocks) */
57 QMap<Color::Color, GameEntity *> m_death;
58
59 /* my local color */
60 Color::Color m_color;
61
62 /* a actor can only eat his upper neighbour
63 * the order of the neighbours is determined by the colors order (sent from server)
64 * please note that !pl1.canEat(pl2, ...) doesn't necessarily mean that pl2 can eat pl1
65 * order MUST be in this format: [col1, [col2 ... colN], col1]
66 */
67 QList<Color::Color> m_eatingorder;
68
69 /* points left before round ends */
70 unsigned int m_pointsLeft;
71 QGraphicsTextItem *m_overlayText;
72};
73
74#endif // SCENEHOLDER_H