aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/api/AI.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/crepe/api/AI.cpp')
-rw-r--r--src/crepe/api/AI.cpp33
1 files changed, 21 insertions, 12 deletions
diff --git a/src/crepe/api/AI.cpp b/src/crepe/api/AI.cpp
index 2195249..2fedaf4 100644
--- a/src/crepe/api/AI.cpp
+++ b/src/crepe/api/AI.cpp
@@ -8,8 +8,9 @@ namespace crepe {
AI::AI(game_object_id_t id, float max_force) : Component(id), max_force(max_force) {}
-void AI::make_circle_path(float radius, const vec2 & center, float start_angle,
- bool clockwise) {
+void AI::make_circle_path(
+ float radius, const vec2 & center, float start_angle, bool clockwise
+) {
if (radius <= 0) {
throw std::runtime_error("Radius must be greater than 0");
}
@@ -25,19 +26,25 @@ void AI::make_circle_path(float radius, const vec2 & center, float start_angle,
if (clockwise) {
for (float i = start_angle; i < 2 * M_PI + start_angle; i += step) {
- path.push_back(vec2{static_cast<float>(center.x + radius * cos(i)),
- static_cast<float>(center.y + radius * sin(i))});
+ path.push_back(vec2 {
+ static_cast<float>(center.x + radius * cos(i)),
+ static_cast<float>(center.y + radius * sin(i))
+ });
}
} else {
for (float i = start_angle; i > start_angle - 2 * M_PI; i -= step) {
- path.push_back(vec2{static_cast<float>(center.x + radius * cos(i)),
- static_cast<float>(center.y + radius * sin(i))});
+ path.push_back(vec2 {
+ static_cast<float>(center.x + radius * cos(i)),
+ static_cast<float>(center.y + radius * sin(i))
+ });
}
}
}
-void AI::make_oval_path(float radius_x, float radius_y, const vec2 & center, float start_angle,
- bool clockwise, float rotation) {
+void AI::make_oval_path(
+ float radius_x, float radius_y, const vec2 & center, float start_angle, bool clockwise,
+ float rotation
+) {
if (radius_x <= 0 && radius_y <= 0) {
throw std::runtime_error("Radius must be greater than 0");
}
@@ -73,14 +80,16 @@ void AI::make_oval_path(float radius_x, float radius_y, const vec2 & center, flo
if (clockwise) {
for (float i = start_angle; i < 2 * M_PI + start_angle; i += step) {
- vec2 point = {static_cast<float>(center.x + radius_x * cos(i)),
- static_cast<float>(center.y + radius_y * sin(i))};
+ vec2 point
+ = {static_cast<float>(center.x + radius_x * cos(i)),
+ static_cast<float>(center.y + radius_y * sin(i))};
path.push_back(rotate_point(point, center));
}
} else {
for (float i = start_angle; i > start_angle - 2 * M_PI; i -= step) {
- vec2 point = {static_cast<float>(center.x + radius_x * cos(i)),
- static_cast<float>(center.y + radius_y * sin(i))};
+ vec2 point
+ = {static_cast<float>(center.x + radius_x * cos(i)),
+ static_cast<float>(center.y + radius_y * sin(i))};
path.push_back(rotate_point(point, center));
}
}