Coverage report for gui


src/
File: src/render/scenes/Starlings.hpp
Date: 2024-06-25 10:57:02
Lines:
0/25
0.0%
Functions:
0/3
0.0%
Branches:
0/16
0.0%

Line Branch Exec Source
1 /*
2 ** EPITECH PROJECT, 2024
3 ** zappy
4 ** File description:
5 ** Starlings
6 */
7
8 #ifndef STARLINGS_HPP_
9 #define STARLINGS_HPP_
10
11 #include <SFML/Graphics.hpp>
12
13 #include "../../utils/Lerp.hpp"
14 #include "../../utils/Random.hpp"
15
16 class Starlings {
17 public:
18 ✗ Starlings() {
19 _rotation = Random::random(0, 360);
20 ✗ respawn();
21 ✗ }
22
23 ✗ void respawn() {
24 int edge = Random::random(0, 4);
25 ✗ if (edge == 0)
26 ✗ _pos = sf::Vector2f(Random::random(0, 1920), 0);
27 ✗ else if (edge == 1)
28 ✗ _pos = sf::Vector2f(Random::random(0, 1920), 1080);
29 ✗ else if (edge == 2)
30 ✗ _pos = sf::Vector2f(0, Random::random(0, 1080));
31 else
32 ✗ _pos = sf::Vector2f(1920, Random::random(0, 1080));
33 edge = Random::random(0, 4);
34 ✗ if (edge == 0)
35 ✗ _target = sf::Vector2f(Random::random(0, 1920), 0);
36 ✗ else if (edge == 1)
37 ✗ _target = sf::Vector2f(Random::random(0, 1920), 1080);
38 ✗ else if (edge == 2)
39 ✗ _target = sf::Vector2f(0, Random::random(0, 1080));
40 else
41 ✗ _target = sf::Vector2f(1920, Random::random(0, 1080));
42 ✗ }
43
44 ✗ void update(float fElapsedTime) {
45 ✗ _pos = Lerp::moveTo(_pos, _target, 100 * fElapsedTime, 5.f);
46 ✗ if (_pos.x == _target.x && _pos.y == _target.y)
47 ✗ respawn();
48 ✗ _rotation += fElapsedTime * 10;
49 ✗ }
50
51 float _rotation = 0;
52 sf::Vector2f _pos;
53 sf::Vector2f _target;
54 protected:
55 private:
56 };
57
58 #endif /* !STARLINGS_HPP_ */
59