diff options
| author | manuel <manuel@mausz.at> | 2011-04-17 19:54:02 +0200 |
|---|---|---|
| committer | manuel <manuel@mausz.at> | 2011-04-17 19:54:02 +0200 |
| commit | 19c9c38d28cdaafcc1b496027f53dcd1914037cf (patch) | |
| tree | 416d1efa5ed1dd9fdcea55cb5794fdb25d3bbb87 /pacman-c++/gameentity.h | |
| parent | 65195fdab6262d31056c74f922376de3b009943c (diff) | |
| download | foop-19c9c38d28cdaafcc1b496027f53dcd1914037cf.tar.gz foop-19c9c38d28cdaafcc1b496027f53dcd1914037cf.tar.bz2 foop-19c9c38d28cdaafcc1b496027f53dcd1914037cf.zip | |
get rid of two dynamic_casts and use qgraphicitem_cast which is A LOT faster (it makes use of static casts)
Diffstat (limited to 'pacman-c++/gameentity.h')
| -rw-r--r-- | pacman-c++/gameentity.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/pacman-c++/gameentity.h b/pacman-c++/gameentity.h index 2fde095..92b485e 100644 --- a/pacman-c++/gameentity.h +++ b/pacman-c++/gameentity.h | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | #include "constants.h" | 4 | #include "constants.h" |
| 5 | #include "pixmapitem.h" | 5 | #include "pixmapitem.h" |
| 6 | #include <QtGlobal> | 6 | #include <QtGlobal> |
| 7 | #include <QDebug> | ||
| 7 | 8 | ||
| 8 | class Actor; | 9 | class Actor; |
| 9 | 10 | ||
| @@ -14,6 +15,12 @@ class GameEntity | |||
| 14 | : public PixmapItem | 15 | : public PixmapItem |
| 15 | { | 16 | { |
| 16 | public: | 17 | public: |
| 18 | enum | ||
| 19 | { | ||
| 20 | Type = UserType + 1 | ||
| 21 | }; | ||
| 22 | |||
| 23 | public: | ||
| 17 | GameEntity(Color::Color color = Color::none, QGraphicsItem *parent = 0); | 24 | GameEntity(Color::Color color = Color::none, QGraphicsItem *parent = 0); |
| 18 | GameEntity(QGraphicsItem *parent); | 25 | GameEntity(QGraphicsItem *parent); |
| 19 | virtual ~GameEntity() | 26 | virtual ~GameEntity() |
| @@ -52,7 +59,14 @@ public: | |||
| 52 | virtual void onDie(Actor *) | 59 | virtual void onDie(Actor *) |
| 53 | {}; | 60 | {}; |
| 54 | 61 | ||
| 62 | /* enable the use of qgraphicsitem_cast with this item */ | ||
| 63 | int type() const | ||
| 64 | { | ||
| 65 | return m_type; | ||
| 66 | } | ||
| 67 | |||
| 55 | protected: | 68 | protected: |
| 69 | int m_type; | ||
| 56 | bool m_eaten; | 70 | bool m_eaten; |
| 57 | Color::Color m_color; | 71 | Color::Color m_color; |
| 58 | }; | 72 | }; |
