diff options
author | max-001 <maxsmits21@kpnmail.nl> | 2024-12-10 08:48:06 +0100 |
---|---|---|
committer | max-001 <maxsmits21@kpnmail.nl> | 2024-12-10 08:48:06 +0100 |
commit | c8d05f759bb1be0ec99e8f23eaa65c80c36ce03d (patch) | |
tree | 8d176b831b9619cffc953f368be2eefc9e52c8ca /src/crepe/api/AI.cpp | |
parent | e5e2eefc7f0f6199fe2b36688b2ad64a97784717 (diff) |
Implemented feedback
Diffstat (limited to 'src/crepe/api/AI.cpp')
-rw-r--r-- | src/crepe/api/AI.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/crepe/api/AI.cpp b/src/crepe/api/AI.cpp index 00e5b37..472550b 100644 --- a/src/crepe/api/AI.cpp +++ b/src/crepe/api/AI.cpp @@ -1,10 +1,17 @@ +#include <stdexcept> + #include "AI.h" 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, 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"); + } + // The step size is determined by the radius (step size is in radians) float step = 400.0f / radius; // Force at least 16 steps (in case of a small radius) @@ -27,8 +34,12 @@ void AI::make_circle_path(float radius, vec2 center, float start_angle, bool clo } } -void AI::make_oval_path(float radius_x, float radius_y, vec2 center, float start_angle, +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"); + } + float max_radius = std::max(radius_x, radius_y); // The step size is determined by the radius (step size is in radians) float step = 400.0f / max_radius; |