X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fmap%2FEntity.h;h=872ad0c92ed739ea1e714da24b132d1870223e3d;hb=9f352d64f920f46a2d5b4fe67408154629933293;hp=d6ba5f3a3763dc2acd3aefd4697fde9d33bef8c5;hpb=657eed00ae73b8d06470cec0d955aeada537a90d;p=l2e.git diff --git a/src/map/Entity.h b/src/map/Entity.h index d6ba5f3..872ad0c 100644 --- a/src/map/Entity.h +++ b/src/map/Entity.h @@ -23,6 +23,17 @@ public: Entity(); ~Entity() { } +public: + enum Orientation { + ORIENTATION_NORTH = 0, + ORIENTATION_EAST = 1, + ORIENTATION_SOUTH = 2, + ORIENTATION_WEST = 3, + }; + enum Flags { + FLAG_NONBLOCKING = 0x01, + }; + public: geometry::Vector &Position() { return position; } const geometry::Vector &Position() const { return position; } @@ -30,21 +41,50 @@ public: geometry::Vector &Velocity() { return velocity; } const geometry::Vector &Velocity() const { return velocity; } - void SetSprite(const graphics::Sprite *s) { sprite = s; } - graphics::AnimationRunner &Animation() { return animation; } - const graphics::AnimationRunner &Animation() const { return animation; } + geometry::Vector &SpriteOffset() { return spriteOffset; } + const geometry::Vector &SpriteOffset() const { return spriteOffset; } + + void SetAnimation(const graphics::Animation *a); + void StartAnimation(app::Application &ctrl); + void StartAnimation(app::State &ctrl); + void StopAnimation(); + bool AnimationRunning() const { return runner.Running(); } + + void SetOrientation(Orientation); + Orientation GetOrientation() const { return orientation; } + void SetSpeed(float); - bool TileLock(int width, int height) const; + void SetFlags(int f) { flags = f; } + bool Blocking() const { return !(flags & FLAG_NONBLOCKING); } + bool Hostile() const { + // NOTE: this is a stub for testing! + return Blocking(); + } + + Entity *Follower() { return follower; } + const Entity *Follower() const { return follower; } + void AddFollower(Entity *); + void RemoveFollower(Entity *); + + bool TileLock(const geometry::Vector &tileSize) const; void Update(float deltaT); void Render(SDL_Surface *, const geometry::Vector &offset) const; private: - const graphics::Sprite *sprite; - graphics::AnimationRunner animation; + void UpdateVelocity(); + +private: + Entity *follower; + const graphics::Animation *animation; + graphics::AnimationRunner runner; + geometry::Vector spriteOffset; geometry::Vector position; geometry::Vector velocity; + Orientation orientation; + float speed; + int flags; };