]> git.localhorst.tv Git - l2e.git/blob - src/map/Entity.h
start/stop animation of player character
[l2e.git] / src / map / Entity.h
1 /*
2  * Entity.h
3  *
4  *  Created on: Sep 29, 2012
5  *      Author: holy
6  */
7
8 #ifndef MAP_ENTITY_H_
9 #define MAP_ENTITY_H_
10
11 #include "../geometry/Vector.h"
12 #include "../graphics/fwd.h"
13 #include "../graphics/Animation.h"
14
15 #include <functional>
16 #include <SDL.h>
17
18 namespace map {
19
20 class Entity {
21
22 public:
23         Entity();
24         ~Entity() { }
25
26 public:
27         enum Orientation {
28                 ORIENTATION_NORTH = 0,
29                 ORIENTATION_EAST = 1,
30                 ORIENTATION_SOUTH = 2,
31                 ORIENTATION_WEST = 3,
32         };
33
34 public:
35         geometry::Vector<float> &Position() { return position; }
36         const geometry::Vector<float> &Position() const { return position; }
37
38         geometry::Vector<float> &Velocity() { return velocity; }
39         const geometry::Vector<float> &Velocity() const { return velocity; }
40
41         void SetAnimation(const graphics::Animation *a);
42         void StartAnimation(app::Application &ctrl) { runner.Start(ctrl); }
43         void StartAnimation(app::State &ctrl) { runner.Start(ctrl); }
44         void StopAnimation() { runner.Stop(); }
45         bool AnimationRunning() const { return runner.Running(); }
46
47         void SetOrientation(Orientation);
48         Orientation GetOrientation() const { return orientation; }
49         void SetSpeed(float);
50
51         bool TileLock(int width, int height) const;
52
53         void Update(float deltaT);
54
55         void Render(SDL_Surface *, const geometry::Vector<int> &offset) const;
56
57 private:
58         void UpdateVelocity();
59
60 private:
61         const graphics::Animation *animation;
62         graphics::AnimationRunner runner;
63         geometry::Vector<float> position;
64         geometry::Vector<float> velocity;
65         Orientation orientation;
66         float speed;
67
68 };
69
70 }
71
72 #endif /* MAP_ENTITY_H_ */