From ce48af53646cd9e7ec762fc1ac176b3aa620b11d Mon Sep 17 00:00:00 2001 From: manuel Date: Thu, 5 May 2011 00:57:07 +0200 Subject: - refactorized the whole project and made a few subprojects - replaced tcp with enet - added connect dialog - some smaller bugfixes --- pacman-c++/common/gameentity.h | 72 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 pacman-c++/common/gameentity.h (limited to 'pacman-c++/common/gameentity.h') diff --git a/pacman-c++/common/gameentity.h b/pacman-c++/common/gameentity.h new file mode 100644 index 0000000..116fae5 --- /dev/null +++ b/pacman-c++/common/gameentity.h @@ -0,0 +1,72 @@ +#ifndef GAMEENTITY_H +#define GAMEENTITY_H + +#include "constants.h" +#include "pixmapitem.h" +#include +#include + +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 -- cgit v1.2.3