#ifndef CLASS_ELEMENT #define CLASS_ELEMENT #include #include #include "graphic/Image.h" #include "IsoObject.h" #include "Attributes.h" #include "Values.h" #define NUM_VIEWS 8 /* views */ #define NORTH 0 #define NORTH_EAST 1 #define EAST 2 #define SOUTH_EAST 3 #define SOUTH 4 #define SOUTH_WEST 5 #define WEST 6 #define NORTH_WEST 7 #define NO_DIRECTION 8 #define SELF -1 #define ANY 8 /* types of element */ #define SCENE_ELEMENT 0 #define BUILDING 1 #define UNIT 2 #define TERRAIN_ELEMENT 3 /// A base class for elements that can be present on the landscape /// DO NOT USE this class for create objects, USE its subclasses (Unit, SceneElement, Building) class Element : public IsoObject, public Attributes { protected: /// images of the element std::vector < graphic::Image * > _views; /// type of the element std::string _type; /// direction of the element int _direction; public: /// Base constructor Element () { }; /// Constructor Element(int r, int c, Statsmap stats) : IsoObject(r, c), Attributes(stats) { }; Element(int r, int c, std::vector components) : IsoObject(r, c), Attributes(components) { }; /// Full constructor Element(int r, int c, std::vector < graphic::Image * > views, Statsmap stats); Element(int r, int c, std::vector < graphic::Image * > views, Statsmap stats, Stringmap strings); Element(int r, int c, std::vector < graphic::Image * > views, std::vector components); /// Destroyer virtual ~Element(); /// set the image that should be blitted virtual void SetDirection(int direction) { _direction = direction; if(direction != NO_DIRECTION) _img = _views[direction]; else _img = _views[SOUTH]; }; /// return direction value int GetDirection() { return _direction; }; /// return the type of the element std::string GetType() { return _type;}; /// flip image and direction void Flip() { // flip direction _direction = (_direction + (NUM_VIEWS / 2)) % NUM_VIEWS; // set view _img = _views[_direction]; }; graphic::Image * GetImg(int ind) { return _views[ind]; }; }; #endif