summaryrefslogtreecommitdiffstats
path: root/pacman-c++/block.h
blob: abfbc5a3ee1633b4ffe8367430dd42957a209bfd (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
#ifndef BLOCK_H
#define BLOCK_H

#include "gameentity.h"
#include "constants.h"
#include <QMap>

class Block
  : public GameEntity
{
public:
  enum Neighbour
  {
    None  = 0,
    Left  = (1 << 0),
    Right = (1 << 1),
    Up    = (1 << 2),
    Down  = (1 << 3)
  };

  enum
  {
    Type = UserType + Transmission::block
  };

public:
  Block(Color::Color color, unsigned int neighbours = None, QGraphicsItem *parent = 0);
  virtual ~Block()
  {};

  unsigned int neighbours();
  void setNeighbours(unsigned int neighbours);
  virtual bool checkEnter(Actor *actor);
  virtual EnteredState enter(Actor *actor);
  virtual void onDie(Actor *);

private:
  // map for saving QPixmaps for reuse
  static QMap<Color::Color, QPixmap> m_pixmaps;
  unsigned int m_neighbours;
};

#endif  // BLOCK_H