X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fmap%2FEntity.h;h=44ba00f682c8eff04e574be39141dfe89902393b;hb=667e1d9c6a78d0b608b518a4e5b5c31bc30e4e89;hp=8832fca31aab4d8253120732cc84d0aedafc4276;hpb=1907ca03c5e865c4d398170042aa384c67ffff29;p=l2e.git diff --git a/src/map/Entity.h b/src/map/Entity.h index 8832fca..44ba00f 100644 --- a/src/map/Entity.h +++ b/src/map/Entity.h @@ -1,17 +1,17 @@ -/* - * Entity.h - * - * Created on: Sep 29, 2012 - * Author: holy - */ - #ifndef MAP_ENTITY_H_ #define MAP_ENTITY_H_ -#include "../battle/fwd.h" -#include "../battle/Monster.h" -#include "../geometry/Vector.h" -#include "../graphics/fwd.h" +namespace app { + class Application; + class State; +} +namespace battle { + class Monster; + class PartyLayout; +} + +#include "../math/Fixed.h" +#include "../math/Vector.h" #include "../graphics/Animation.h" #include @@ -45,20 +45,20 @@ public: public: /// Pixel resolved position of the entity's top left corner on the map. - geometry::Vector &Position() { return position; } - const geometry::Vector &Position() const { return position; } + math::Vector > &Position() { return position; } + const math::Vector > &Position() const { return position; } /// Velocity of the entity in pixels per second. - geometry::Vector &Velocity() { return velocity; } - const geometry::Vector &Velocity() const { return velocity; } + math::Vector > &Velocity() { return velocity; } + const math::Vector > &Velocity() const { return velocity; } /// Offset of the entity's sprite's to left corner relative to Position(). - geometry::Vector &SpriteOffset() { return spriteOffset; } - const geometry::Vector &SpriteOffset() const { return spriteOffset; } + math::Vector &SpriteOffset() { return spriteOffset; } + const math::Vector &SpriteOffset() const { return spriteOffset; } /// Reset the entity to the stored tile coordinates (usually set when /// loading game data). - void ResetPosition(const geometry::Vector &tileSize) { position = tilePosition * tileSize; } + void ResetPosition(const math::Vector &tileSize) { position = tilePosition * tileSize; } /// Set the animation to use for animated entities. /// For orientable entities, the animation should have north, south, east, @@ -80,13 +80,18 @@ public: /// west sprites at offsets (0,0), (1,0), (2,0), and (3,0) respectively. void SetSprite(const graphics::Sprite *s) { sprite = s; } - /// Change the entity's orientation to given one. - /// If the entity is moving, velocity is changed accordingly. + /// Change the entity's facing direction. + /// If the entity is moving, velocity is untouched. void SetOrientation(Orientation); Orientation GetOrientation() const { return orientation; } + /// Change the entity's orientation to given one. + /// If the entity is moving, velocity is changed accordingly. + /// Also changes the orientation to given direction. + void SetDirection(Orientation); + Orientation GetDirection() const { return direction; } /// Set the entity's speed in pixels per second. - /// This speed is then combined with the orientation to form a velocity. - void SetSpeed(float); + /// This speed is then combined with the direction to form a velocity. + void SetSpeed(math::Fixed<8>); /// Change to a natural, relaxed animation state (row offset 0). void SetHandsFree(); @@ -117,9 +122,9 @@ public: /// Add monsters. This will cause the entity to be Hostile() and result in a /// battle scene with given monsters when touched. - void SetMonsters(battle::Monster *m, int num) { monsters = m; numMonsters = num; } - battle::Monster *MonstersBegin() { return monsters; } - battle::Monster *MonstersEnd() { return monsters + numMonsters; } + void SetMonsters(battle::Monster **m, int num) { monsters = m; numMonsters = num; } + battle::Monster **MonstersBegin() { return monsters; } + battle::Monster **MonstersEnd() { return monsters + numMonsters; } /// Get an entity that should follow in this one's steps or 0 if none. Entity *Follower() { return follower; } @@ -131,12 +136,12 @@ public: void RemoveFollower(Entity *); /// Check if position locks into grid defined by given tileSize. - bool TileLock(const geometry::Vector &tileSize) const; + bool TileLock(const math::Vector &tileSize) const; /// Integrate this entity's physical properties over given time interval. - void Update(float deltaT); + void Update(Uint32 deltaT); - void Render(SDL_Surface *, const geometry::Vector &offset) const; + void Render(SDL_Surface *, const math::Vector &offset) const; static void CreateTypeDescription(); static void Construct(void *); @@ -150,19 +155,20 @@ private: const graphics::Animation *animation; const graphics::Sprite *sprite; battle::PartyLayout *partyLayout; - battle::Monster *monsters; + battle::Monster **monsters; int numMonsters; graphics::AnimationRunner runner; - geometry::Vector spriteOffset; - geometry::Vector tilePosition; - geometry::Vector position; - geometry::Vector velocity; + math::Vector spriteOffset; + math::Vector tilePosition; + math::Vector > position; + math::Vector > velocity; + Orientation direction; Orientation orientation; - float speed; + math::Fixed<8> speed; int flags; }; } -#endif /* MAP_ENTITY_H_ */ +#endif