summaryrefslogtreecommitdiffstats
path: root/pacman-c++/actor.h
blob: 965d2407050abc423ea3468e8546ef5dd00e1445 (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
#ifndef ACTOR_H
#define ACTOR_H

#include "pixmapitem.h"
#include "constants.h"
#include <QtCore/QSequentialAnimationGroup>
#include <QtCore/QParallelAnimationGroup>
#include <QList>

class Actor
  : public PixmapItem
{
Q_OBJECT

public:
  enum Movement {
    None    = 0,
    Left,
    Right,
    Up,
    Down,
  };

  Actor(Color::Color color, bool local = false, QGraphicsItem *parent = 0);
  virtual ~Actor() {};

  QSequentialAnimationGroup *setupEatingAnimation(Actor::Movement direction);
  Color::Color getColor();
  PixmapItem &getIcon();
  bool isLocal();
  void move(Movement direction);
  bool isMoving();
  void die();
  void eatingCherry();

  unsigned int getRoundPoints() { return m_roundPoints; }
  unsigned int getGamePoints() { return m_gamePoints; }

  void addRoundPoints(unsigned int amount) { m_roundPoints += amount; }
  void finishRound() { m_gamePoints += m_roundPoints; m_roundPoints = 0; }

private slots:
  void enqueue();

private:
  QPixmap m_pix;
  Color::Color m_color;
  Movement m_direction;
  PixmapItem m_icon;
  bool m_local;

  unsigned int m_roundPoints, m_gamePoints;

  QList<PixmapItem *> m_images;
  QList<QSequentialAnimationGroup *> m_eating;
  QParallelAnimationGroup *m_moving;
};

#endif // ACTOR_H