Coverage report for gui


src/
File: src/render/scenes/world/Chunck.hpp
Date: 2024-06-25 10:57:02
Lines:
0/21
0.0%
Functions:
0/3
0.0%
Branches:
0/22
0.0%

Line Branch Exec Source
1 /*
2 ** EPITECH PROJECT, 2024
3 ** zappy
4 ** File description:
5 ** chunck
6 */
7
8 #ifndef CHUNCK_HPP_
9 #define CHUNCK_HPP_
10
11 #include <SFML/Graphics.hpp>
12 #include <vector>
13 #include "../../sprites/Sprite.hpp"
14 #include <memory>
15 #include <utility>
16 #include "../../core/Setting.hpp"
17 #include "../../../utils/Random.hpp"
18
19 class Chunck {
20 public:
21 Chunck() {}
22 ~Chunck() {}
23
24 sf::Vector2f _pos;
25 float _yOffset;
26 bool _hover = false;
27
28 void addElement(std::shared_ptr<Sprite> element) {
29 sf::Vector2f offset = sf::Vector2f(
30 Random::random(0, 26) - 13,
31 Random::random(0, 26) - 13
32 );
33 sf::Vector2f pos = getMiddle() + offset;
34 _enviromentElements.push_back(std::make_pair(element, pos));
35 }
36 void draw(sf::RenderWindow &window) {
37 if (_enviromentElements.size() == 1) {
38 auto element = _enviromentElements[0];
39 element.first->setPosition(element.second);
40 element.first->draw(window);
41 }
42 else if (_enviromentElements.size() == 2) {
43 auto element1 = _enviromentElements[0];
44 auto element2 = _enviromentElements[1];
45 element1.first->setPosition(element1.second);
46 element2.first->setPosition(element2.second);
47
48 if (element1.second.y < element2.second.y) {
49 element1.first->draw(window);
50 element2.first->draw(window);
51 } else {
52 element2.first->draw(window);
53 element1.first->draw(window);
54 }
55 }
56 }
57
58 sf::Vector2f getMiddle() {
59 return sf::Vector2f(
60 _pos.x,
61 _pos.y + _yOffset - TILE_SIZE_MY
62 );
63 }
64
65 std::vector<int> _inventory = {0, 0, 0, 0, 0, 0, 0};
66 int _nbTrantorians = 0;
67 private:
68 std::vector<std::pair<std::shared_ptr<Sprite>, sf::Vector2f>> _enviromentElements;
69
70 };
71
72 #endif /* !CHUNCK_HPP_ */
73