player: change direction even if we can't move
[Tsunagari.git] / src / entity.h
blobec7f7051cea59a37ef42d58c5760f9a17c4ce14d
1 /******************************
2 ** Tsunagari Tile Engine **
3 ** entity.h **
4 ** Copyright 2011 OmegaSDG **
5 ******************************/
7 #ifndef ENTITY_H
8 #define ENTITY_H
10 #include <string>
12 #include <boost/scoped_ptr.hpp>
14 #include "common.h"
15 #include "sprite.h"
17 class Area;
18 class Resourcer;
20 //! Entity Class
21 /*!
22 This class handles dynamic game objects, such as monsters, NPCs, and
23 items.
25 class Entity
27 public:
28 //! Entity Constructor
29 Entity(Resourcer* rc, Area* area, const std::string& descriptor);
31 //! Entity Destructor
32 virtual ~Entity();
34 //! Entity Initializer
35 bool init();
37 //! Gosu Callback
38 void draw();
40 //! Gosu Callback
41 bool needsRedraw() const;
43 //! Retrieve entity's absolute position.
44 coord_t getCoordsByPixel();
46 //! Retrieve entity's tile position.
47 coord_t getCoordsByTile();
49 //! Move the entity by dx, dy.
50 virtual void moveByTile(coord_t delta);
52 //! Set location to Tile at {x, y, z}.
53 void setCoordsByTile(coord_t pos);
55 //! Sets the Area object this entity will ask when looking for
56 // nearby Tiles. Doesn't change x,y,z position.
57 void setArea(Area* area);
59 protected:
60 bool processDescriptor();
61 bool processPlayerDescriptor(const xmlNode* root);
63 virtual void postMove();
65 Resourcer* rc;
66 Sprite sprite;
67 Area* area;
68 bool redraw;
70 enum entityType {
71 PLAYER
74 const std::string descriptor;
75 std::string spriteDescriptor;
76 entityType type;
79 #endif