diff options
author | Yann Herklotz <ymherklotz@gmail.com> | 2017-04-07 17:57:53 +0100 |
---|---|---|
committer | Yann Herklotz <ymherklotz@gmail.com> | 2017-04-07 17:57:53 +0100 |
commit | 884caeb57d6b0b94a21df4412f39d81925e58000 (patch) | |
tree | ea5d55f6d857b448320fa9eab92dc83eeafcc1b3 /include | |
parent | 7d1ab6bd8a1e9711fb99d29b350437fb7784ddc4 (diff) | |
download | Arider-884caeb57d6b0b94a21df4412f39d81925e58000.tar.gz Arider-884caeb57d6b0b94a21df4412f39d81925e58000.zip |
Improved animation class and added background
Diffstat (limited to 'include')
-rw-r--r-- | include/animation.hpp | 26 | ||||
-rw-r--r-- | include/levelloader.hpp | 16 |
2 files changed, 33 insertions, 9 deletions
diff --git a/include/animation.hpp b/include/animation.hpp index 122dc91..da24fd5 100644 --- a/include/animation.hpp +++ b/include/animation.hpp @@ -10,31 +10,39 @@ #include <unordered_map> #include <vector> +enum class AnimationState +{ + IDLE, + MOVING, + JUMPING, + CROUCHING, +}; + class Animation { private: - std::unordered_map<std::string, std::vector<yage::Texture>> frame_animations_; - std::string current_animation_; + std::unordered_map<AnimationState, std::vector<yage::Texture>> frame_animations_; + AnimationState current_animation_; int current_index_=0; public: - Animation() {} + Animation(); - void pushFrame(const std::string &animation_name, const std::string &texture_path); + void pushFrame(AnimationState state, const std::string &texture_path); yage::Texture currentFrame() const; - void start(const std::string &animation_name); + void start(AnimationState state); void nextFrame(); template<typename First, typename Second, typename ...Rest> - void initializeAnimation(const std::string &animation_name, First &&first, Second &&second, Rest &&...rest) + void initializeAnimation(AnimationState state, First &&first, Second &&second, Rest &&...rest) { - frame_animations_[animation_name].push_back(yage::ResourceManager::getTexture(std::forward<First>(first))); + frame_animations_[state].push_back(yage::ResourceManager::getTexture(std::forward<First>(first))); initializeAnimation(std::forward<Second>(second), std::forward<Rest>(rest)...); } template<typename Last> - void initializeAnimation(const std::string &animation_name, Last &&last) + void initializeAnimation(AnimationState state, Last &&last) { - frame_animations_[animation_name].push_back(yage::ResourceManager::getTexture(std::forward<Last>(last))); + frame_animations_[state].push_back(yage::ResourceManager::getTexture(std::forward<Last>(last))); } }; diff --git a/include/levelloader.hpp b/include/levelloader.hpp new file mode 100644 index 0000000..3d11a00 --- /dev/null +++ b/include/levelloader.hpp @@ -0,0 +1,16 @@ +#ifndef LEVEL_LOADER_HPP +#define LEVEL_LOADER_HPP + +#include "player.hpp" + +#include <YAGE/spritebatch.hpp> + +#include <string> + +class LevelLoader { +public: + static void loadLevel(const std::string &level_path, std::string &level, int &level_width, int &level_height); + static void drawLevel(yage::SpriteBatch &sprite_batch, const std::string &level, int level_width); +}; + +#endif |