R-Type
R-Type project
HowToPlayAnimation.hpp
1 /*
2 ** EPITECH PROJECT, 2022
3 ** RType
4 ** File description:
5 ** HowToPlayAnimation
6 */
7 
8 #ifndef HOWTOPLAYANIMATION_HPP_
9 #define HOWTOPLAYANIMATION_HPP_
10 
11 #include "KapEngine.hpp"
12 #include "KapEngineDebug.hpp"
13 #include "KapEngineUi.hpp"
14 #include "Keys/ChangeKey.hpp"
15 #include "SpriteAnimation.hpp"
16 #include <unordered_map>
17 
18 namespace RType {
20  public:
21  HowToPlayAnimation(std::string name, std::shared_ptr<KapEngine::GameObject> gameObject);
22  ~HowToPlayAnimation() = default;
23 
24  void onFixedUpdate() override;
25  void onResetAnim() override;
26  void setNbAnimations(std::string name, int nb);
27  void setResetPosition(std::string name, KapEngine::Tools::Vector3 position);
28  void setRect(std::string name, KapEngine::Tools::Rectangle rect);
29  KapEngine::Tools::Rectangle getRect(std::string name);
30  void addSpriteAnimation(std::string name, std::shared_ptr<KapEngine::GameObject> gameObject);
31 
32  private:
33  // Variables
34  std::unordered_map<std::string, int> _nbAnimation;
35  std::unordered_map<std::string, KapEngine::Tools::Rectangle> _rect;
36  std::unordered_map<std::string, KapEngine::Tools::Vector3> _allGoResetPosition;
37  std::unordered_map<std::string, std::shared_ptr<KapEngine::GameObject>> _allGameObject;
38  float _speed = 0.1f;
39  bool _boubouleInvert = false;
40  bool _bouboule2Invert = false;
41  bool _shipInvert = false;
42  bool _explosionInvert = false;
43  bool _explosionInvert2 = false;
44  bool _bulletReset = false;
45  bool _canShoot = true;
46  bool _shipAnimation = false;
47  int _nbShoot = 0;
48 
49  // Functions
50  void init(std::shared_ptr<KapEngine::GameObject> gameObject);
51  void onResetStates();
52  void onResetRect();
53  void onResetPosition();
54  void onResetActive();
55  KapEngine::UI::Image &getImage(std::string name);
56  SpriteAnimation &getSpriteAnimation(std::string name);
57  KapEngine::Tools::Vector3 getResetPosition(std::string name);
58  std::shared_ptr<KapEngine::GameObject> &getGameObject(std::string name);
59 
60  void moveBouboule();
61  void moveBouboule2();
62  void moveShip();
63  void moveBullet();
64  void moveExplosion();
65  };
66 } // namespace RType
67 
68 #endif /* !HOWTOPLAYANIMATION_HPP_ */
KapEngine::Component::getGameObject
GameObject & getGameObject() const
Get the Game Object object.
Definition: Component.cpp:35
KapEngine::UI::Image
Definition: UiImage.hpp:35
RType::HowToPlayAnimation::onFixedUpdate
void onFixedUpdate() override
call eachv x ms
Definition: HowToPlayAnimation.cpp:20
RType::HowToPlayAnimation
Definition: HowToPlayAnimation.hpp:19
RType::SpriteAnimation
Definition: SpriteAnimation.hpp:16
KapEngine::Animation
Definition: Animation.hpp:25
KapEngine::Tools::Rectangle
Definition: Rectangle.hpp:23
KapEngine::Tools::Vector3
Definition: Vectors.hpp:251