diff options
| author | manuel <manuel@mausz.at> | 2011-04-12 18:08:02 +0200 |
|---|---|---|
| committer | manuel <manuel@mausz.at> | 2011-04-12 18:08:02 +0200 |
| commit | 651a1bee1adc5318922d1b37b0cea11a65df71e2 (patch) | |
| tree | a60d4921d569f0b4b817e31e049cbc64d11d05f9 /pacman-c++/gameentity.h | |
| parent | fae7c3377c8995b217e620c5cf1e963b3ab1e84a (diff) | |
| download | foop-651a1bee1adc5318922d1b37b0cea11a65df71e2.tar.gz foop-651a1bee1adc5318922d1b37b0cea11a65df71e2.tar.bz2 foop-651a1bee1adc5318922d1b37b0cea11a65df71e2.zip | |
make removal of items from scene delayed by one tick (looks better)
all items are now derived from gameentity and gameentity is derived from pixmapitem:
- this is naturally better
- allows us to add a generic gameentity.color()
Diffstat (limited to 'pacman-c++/gameentity.h')
| -rw-r--r-- | pacman-c++/gameentity.h | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/pacman-c++/gameentity.h b/pacman-c++/gameentity.h index afa3aba..2fde095 100644 --- a/pacman-c++/gameentity.h +++ b/pacman-c++/gameentity.h | |||
| @@ -1,6 +1,8 @@ | |||
| 1 | #ifndef GAMEENTITY_H | 1 | #ifndef GAMEENTITY_H |
| 2 | #define GAMEENTITY_H | 2 | #define GAMEENTITY_H |
| 3 | 3 | ||
| 4 | #include "constants.h" | ||
| 5 | #include "pixmapitem.h" | ||
| 4 | #include <QtGlobal> | 6 | #include <QtGlobal> |
| 5 | 7 | ||
| 6 | class Actor; | 8 | class Actor; |
| @@ -9,12 +11,20 @@ class Actor; | |||
| 9 | * Base class for entities that interact in the game | 11 | * Base class for entities that interact in the game |
| 10 | */ | 12 | */ |
| 11 | class GameEntity | 13 | class GameEntity |
| 14 | : public PixmapItem | ||
| 12 | { | 15 | { |
| 13 | public: | 16 | public: |
| 14 | GameEntity(); | 17 | GameEntity(Color::Color color = Color::none, QGraphicsItem *parent = 0); |
| 18 | GameEntity(QGraphicsItem *parent); | ||
| 15 | virtual ~GameEntity() | 19 | virtual ~GameEntity() |
| 16 | {}; | 20 | {}; |
| 17 | 21 | ||
| 22 | /* color of entity */ | ||
| 23 | virtual Color::Color color() | ||
| 24 | { | ||
| 25 | return m_color; | ||
| 26 | } | ||
| 27 | |||
| 18 | /* returns whether the actor may enter this field */ | 28 | /* returns whether the actor may enter this field */ |
| 19 | virtual bool checkEnter(Actor *) | 29 | virtual bool checkEnter(Actor *) |
| 20 | { | 30 | { |
| @@ -42,9 +52,9 @@ public: | |||
| 42 | virtual void onDie(Actor *) | 52 | virtual void onDie(Actor *) |
| 43 | {}; | 53 | {}; |
| 44 | 54 | ||
| 45 | |||
| 46 | protected: | 55 | protected: |
| 47 | bool m_eaten; | 56 | bool m_eaten; |
| 57 | Color::Color m_color; | ||
| 48 | }; | 58 | }; |
| 49 | 59 | ||
| 50 | #endif // GAMEENTITY_H | 60 | #endif // GAMEENTITY_H |
