R-Type
R-Type project
SpriteAnimation.hpp
1 /*
2 ** EPITECH PROJECT, 2022
3 ** RType
4 ** File description:
5 ** SpriteAnimation
6 */
7 
8 #ifndef SPRITEANIMATION_HPP_
9 #define SPRITEANIMATION_HPP_
10 
11 #include "KapEngine.hpp"
12 #include "KapEngineDebug.hpp"
13 #include "KapEngineUi.hpp"
14 
15 namespace RType {
17  public:
18  SpriteAnimation(std::shared_ptr<KapEngine::GameObject> gameObject);
19  SpriteAnimation(std::shared_ptr<KapEngine::GameObject> gameObject, int nbAnimation, KapEngine::Tools::Rectangle rect,
20  int64_t const &time);
21  ~SpriteAnimation() = default;
22 
23  void onPlay() override;
24  void onUpdateAnim() override;
25  void onResetAnim() override;
26  void setNbAnimations(int nbAnimations, std::size_t xAnims = 0, std::size_t yAnims = 0);
27  void setRect(KapEngine::Tools::Rectangle rect);
28 
34  void bouncingVersion(bool bounce) {
35  if (bounce && !_bounce)
36  _nbAnimation *= 2;
37  if (!bounce && _bounce)
38  _nbAnimation /= 2;
39  _bounce = bounce;
40  }
41 
42  void reverseAnim(bool reverse) { _reverse = reverse; }
43 
44  void setChangeWithY(bool changeWithY) { _changeWithY = changeWithY; }
45 
46  protected:
47  private:
48  // Variables
49  int _nbAnimation = 0;
50  bool _bounce = false;
51  bool _reverse = false;
52  bool _changeWithY = false;
54  std::size_t _nbXTextures;
55  std::size_t _nbYTextures = 0;
56  // Functions
57  void init(std::shared_ptr<KapEngine::GameObject> gameObject);
58  KapEngine::UI::Image &getImage();
59  KapEngine::Tools::Vector2 calculateNewPos(int crossProduct);
60  };
61 } // namespace RType
62 
63 #endif /* !SPRITEANIMATION_HPP_ */
KapEngine::UI::Image
Definition: UiImage.hpp:35
KapEngine::Tools::Vector2
Definition: Vectors.hpp:25
RType::SpriteAnimation
Definition: SpriteAnimation.hpp:16
KapEngine::Animation
Definition: Animation.hpp:25
KapEngine::Tools::Rectangle
Definition: Rectangle.hpp:23
RType::SpriteAnimation::bouncingVersion
void bouncingVersion(bool bounce)
this function must be call after all setter functions it gonne calcul all anims to do
Definition: SpriteAnimation.hpp:34