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

#include "pixmapitem.h"
#include "constants.h"
#include "audio.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 color();
  PixmapItem &icon();
  Movement direction();
  bool isLocal();
  void move(Movement direction);
  bool isMoving();
  void die();
  void eatingCherry();
  AudioPlayer *wakaPlayer();

  unsigned int getRoundPoints();
  unsigned int getGamePoints();
  void addRoundPoints(unsigned int amount);
  void finishRound();

private:
  void moveByServer(Movement direction);

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

  unsigned int m_roundPoints;
  unsigned int m_gamePoints;

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

#endif // ACTOR_H