diff --git a/src/leafy/Button.cpp b/src/leafy/Button.cpp index 65604f7..bb70136 100644 --- a/src/leafy/Button.cpp +++ b/src/leafy/Button.cpp @@ -13,9 +13,10 @@ #include #include -#include -#define _USE_MATH_DEFINES +#ifndef _PI +#define _PI 3.14159265358979323846 +#endif Button::Button(const sf::Vector2f& radius, float pointCount) : m_radius(radius) @@ -59,7 +60,7 @@ std::size_t Button::getPointCount() const } sf::Vector2f Button::getPoint(std::size_t index) const { - float angle = index * 2 * M_PI / getPointCount() - M_PI / 2; + float angle = index * 2 * _PI / getPointCount() - _PI / 2; float x = std::cos(angle) * m_radius.x; float y = std::sin(angle) * m_radius.y; return sf::Vector2f(m_radius.x + x, m_radius.y + y); diff --git a/src/leafy/ConvexShape.cpp b/src/leafy/ConvexShape.cpp index d7e0a28..14f7004 100644 --- a/src/leafy/ConvexShape.cpp +++ b/src/leafy/ConvexShape.cpp @@ -10,7 +10,9 @@ #include -#define _USE_MATH_DEFINES +#ifndef _PI +#define _PI 3.14159265358979323846 +#endif namespace sf { @@ -40,7 +42,7 @@ namespace sf } sf::Vector2f ConvexShape::getPoint(std::size_t index) const { - float angle = index * 2 * M_PI / getPointCount() - M_PI / 2; + float angle = index * 2 * _PI / getPointCount() - _PI / 2; float x = std::cos(angle) * m_radius.x; float y = std::sin(angle) * m_radius.y; return sf::Vector2f(m_radius.x + x, m_radius.y + y); diff --git a/src/leafy/StadiumShape.cpp b/src/leafy/StadiumShape.cpp index f3d9989..3ea246f 100644 --- a/src/leafy/StadiumShape.cpp +++ b/src/leafy/StadiumShape.cpp @@ -9,7 +9,10 @@ #include #include -#define _USE_MATH_DEFINES + +#ifndef _PI +#define _PI 3.14159265358979323846 +#endif sf::StadiumShape::StadiumShape(float radius) : m_size(300.0f, 60.0f), @@ -97,8 +100,8 @@ sf::Vector2f sf::StadiumShape::getPoint(std::size_t index) const break; } - return sf::Vector2f(m_radius * std::cos(delta_angle * (index - center_index) * M_PI / 180.0f) + center.x, - -m_radius * std::sin(delta_angle * (index - center_index) * M_PI / 180.0f) + center.y); + return sf::Vector2f(m_radius * std::cos(delta_angle * (index - center_index) * _PI / 180.0f) + center.x, + -m_radius * std::sin(delta_angle * (index - center_index) * _PI / 180.0f) + center.y); } #undef _USE_MATH_DEFINES