blob: a81a18cc8c4f87f4324fbe572eb444d5c673aa68 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
#include "RandomSpawner.h"
#include <cmath>
#include <kurator/battles/components.h>
#include <kurator/battles/Point.h>
namespace kurator
{
namespace battles
{
RandomSpawner::RandomSpawner(const int total_teams, const double distance, const double variation) :
angle_step {2.0 * M_PI / total_teams},
device {},
distribution_d {distance - distance * variation, distance + distance * variation},
distribution_a {-variation * M_PI, variation * M_PI}
{
}
Transform
RandomSpawner::get(const int team)
{
const double distance = distribution_d(device);
const double angle = angle_step * team + distribution_a(device);
const Point position {
distance * std::cos(angle),
distance * std::sin(angle),
};
return {position, {}};
}
} // namespace battles
} // namespace kurator
|