Peoplemon  0.1.0
Peoplemon 3 game source documentation
RunWalkAnimations.hpp
Go to the documentation of this file.
1 #ifndef CORE_RESOURCES_RUNWALKANIMATIONS_HPP
2 #define CORE_RESOURCES_RUNWALKANIMATIONS_HPP
3 
4 #include <BLIB/Graphics/Animation2D/AnimationData.hpp>
5 #include <BLIB/Resources.hpp>
6 #include <BLIB/Tilemap/Direction.hpp>
7 
8 namespace core
9 {
10 namespace res
11 {
18 class RunWalkAnimations : public bl::gfx::a2d::AnimationData {
19 public:
26  bool loadFromDirectory(const std::string& path);
27 
34  static std::size_t getStateFromDirection(bl::tmap::Direction dir, bool running) {
35  return static_cast<std::size_t>(dir) + (running ? 4 : 0);
36  }
40  float getMaxStateLength() const { return maxLen; }
41 
42 private:
43  float maxLen;
44 };
45 
51 struct RunWalkAnimationLoader : public bl::resource::LoaderBase<RunWalkAnimations> {
61  virtual bool load(const std::string& path, const char*, std::size_t, std::istream&,
62  RunWalkAnimations& result) override;
63 };
64 
65 } // namespace res
66 } // namespace core
67 
68 #endif
Core classes and functionality for both the editor and game.
Extension of animation data that loads and combines the animations for each movement direction into a...
static std::size_t getStateFromDirection(bl::tmap::Direction dir, bool running)
Maps the movement direction to the state index.
bool loadFromDirectory(const std::string &path)
Loads the walking animations from the given directory.
float getMaxStateLength() const
Returns the maximum length of any substate animation in seconds.
Specialized loader for walking animations.
virtual bool load(const std::string &path, const char *, std::size_t, std::istream &, RunWalkAnimations &result) override
Loads the walking animations from the given path.