summaryrefslogtreecommitdiffstats
path: root/pacman-c++/sceneholder.h
blob: 69ee598e3232cd583149aa56eb505e6642e94f94 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#ifndef SCENEHOLDER_H
#define SCENEHOLDER_H

#include "constants.h"
#include <QtGui>

class GameEntity;
class Actor;

class SceneHolder
  : public QGraphicsScene
{
  Q_OBJECT

public:
  SceneHolder(QObject *parent = 0);
  virtual ~SceneHolder()
  {};
  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<Color::Color> &order);
  QList<Color::Color> &eatingOrder();

private slots:
  void decrementPoints();

protected:
  /* 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);

  /* map of all pixmap instances */
  QVector< QVector<GameEntity *> > visualMap;

  /* map of actors in order to keep track of those instances */
  QMap<Color::Color, Actor*> m_actors;

  /* items that got removed/has been eaten
   * must be remove one tick later
   */
  QList<GameEntity *> m_oldItems;

  /* 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<Color::Color> m_eatingorder;

  /* points left before round ends */
  unsigned int m_pointsLeft;
};

#endif // SCENEHOLDER_H