Coverage report for gui


src/
File: src/render/scenes/world/ui/LvlUpAnim.hpp
Date: 2024-06-25 10:57:02
Lines:
0/18
0.0%
Functions:
0/2
0.0%
Branches:
0/24
0.0%

Line Branch Exec Source
1 /*
2 ** EPITECH PROJECT, 2024
3 ** zappy
4 ** File description:
5 ** LvlUpAnim
6 */
7
8 #ifndef LVLUPANIM_HPP_
9 #define LVLUPANIM_HPP_
10
11 #include "../../../sprites/Sprite.hpp"
12
13 class LvlUpAnim {
14 public:
15 LvlUpAnim(int id, sf::Vector2f pos, sf::Vector2f tile, int lvl)
16 : _id(id), _pos(pos), _tile(tile), _lvl(lvl)
17 {
18 _lvlup = std::make_shared<Sprite>("./assets/lvlup.png", 8, 0.1f);
19 _lvlup->setPosition(_pos);
20 }
21 ~LvlUpAnim() {}
22
23 enum class LvlUpAnimState {
24 START,
25 FINISHING,
26 FAILURE
27 };
28
29 void update(float fElapsedTime) {
30 if (_state == LvlUpAnimState::FINISHING)
31 _lvlup->update(fElapsedTime);
32 }
33
34 void draw(sf::RenderWindow &window) {
35 _lvlup->draw(window);
36 }
37
38 bool setSuccess() {
39 bool ret = false;
40 if (_state == LvlUpAnimState::START)
41 ret = true;
42 _state = LvlUpAnimState::FINISHING;
43 return ret;
44 }
45
46 void setFailure() {
47 _state = LvlUpAnimState::FAILURE;
48 }
49
50 bool isFinished() {
51 return (_state == LvlUpAnimState::FINISHING && _lvlup->isFinished()) || _state == LvlUpAnimState::FAILURE;
52 }
53
54 int getId() {
55 return _id;
56 }
57
58 sf::Vector2f getTile() {
59 return _tile;
60 }
61
62 int getLvl() {
63 return _lvl;
64 }
65
66 protected:
67 private:
68 int _id;
69 sf::Vector2f _pos;
70 sf::Vector2f _tile;
71 std::shared_ptr<Sprite> _lvlup;
72 LvlUpAnimState _state = LvlUpAnimState::START;
73 int _lvl;
74 };
75
76 #endif /* !LVLUPANIM_HPP_ */
77