blob: 116fae5a4eddf5068b24e5f6c61a2ca3ab3478d1 (
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
65
66
67
68
69
70
71
72
|
#ifndef GAMEENTITY_H
#define GAMEENTITY_H
#include "constants.h"
#include "pixmapitem.h"
#include <QtGlobal>
#include <QDebug>
class Actor;
/**
* Base class for entities that interact in the game
*/
class GameEntity
: public PixmapItem
{
public:
enum
{
Type = UserType + 1
};
enum EnteredState
{
Nothing,
DestroyedEntity,
DestroyedActor
};
public:
GameEntity(Color::Color color = Color::none, QGraphicsItem *parent = 0);
GameEntity(QGraphicsItem *parent);
virtual ~GameEntity()
{};
/* color of entity */
virtual Color::Color color()
{
return m_color;
}
/* returns whether the actor may enter this field */
virtual bool checkEnter(Actor *)
{
return true;
}
/* performs action when this actor acctually enters
* returns whether this entity survives the entering
*/
virtual EnteredState enter(Actor *)
{
/* default to no action/survive */
return Nothing;
}
/* called when an instance acctually dies for creating effects */
virtual void onDie(Actor *)
{};
/* enable the use of qgraphicsitem_cast with this item */
int type() const
{
return m_type;
}
protected:
int m_type;
Color::Color m_color;
};
#endif // GAMEENTITY_H
|