Replies: 1 comment 3 replies
-
|
I did it myself. It would be good if you could include it in the LDtkLoader code. template <typename T>
inline ldtk::IntPoint operator/(ldtk::IntPoint vec, T divider)
{
return {vec.x / divider, vec.y / divider};
}
template <typename T>
inline ldtk::IntPoint operator*(ldtk::IntPoint vec, T multiplier)
{
return {vec.x * multiplier, vec.y * multiplier};
}
template <typename T>
inline ldtk::IntPoint &operator*=(ldtk::IntPoint &vec, T multiplier)
{
vec.x *= multiplier;
vec.y *= multiplier;
return vec;
}
template <typename T>
inline ldtk::IntPoint &operator/=(ldtk::IntPoint &vec, T multiplier)
{
vec.x /= multiplier;
vec.y /= multiplier;
return vec;
}
inline ldtk::IntPoint operator/(ldtk::IntPoint vec_1, ldtk::IntPoint vec_2)
{
return {vec_1.x / vec_2.x, vec_1.y / vec_2.y};
}
inline ldtk::IntPoint operator*(ldtk::IntPoint vec_1, ldtk::IntPoint vec_2)
{
return {vec_1.x * vec_2.x, vec_1.y * vec_2.y};
}
inline ldtk::IntPoint operator+(ldtk::IntPoint vec_1, ldtk::IntPoint vec_2)
{
return {vec_1.x + vec_2.x, vec_1.y + vec_2.y};
}
inline ldtk::IntPoint operator-(ldtk::IntPoint vec_1, ldtk::IntPoint vec_2)
{
return {vec_1.x - vec_2.x, vec_1.y - vec_2.y};
}
inline ldtk::IntPoint &operator-=(ldtk::IntPoint &vec_1, const ldtk::IntPoint &vec_2)
{
vec_1.x -= vec_2.x;
vec_1.y -= vec_2.y;
return vec_1; // Zwracamy referencję do zmodyfikowanego obiektu
}
inline ldtk::IntPoint &operator+=(ldtk::IntPoint &vec_1, ldtk::IntPoint &vec_2)
{
vec_1.x += vec_2.x;
vec_1.y += vec_2.y;
return vec_1;
}
inline ldtk::IntPoint operator/=(ldtk::IntPoint vec_1, ldtk::IntPoint vec_2)
{
vec_1.x /= vec_2.x;
vec_1.y /= vec_2.y;
return vec_1;
}
inline ldtk::IntPoint operator*=(ldtk::IntPoint vec_1, ldtk::IntPoint vec_2)
{
vec_1.x *= vec_2.x;
vec_1.y *= vec_2.y;
return vec_1;
}
inline bool operator==(ldtk::IntPoint vec_1, ldtk::IntPoint vec_2)
{
return vec_1.x == vec_2.x && vec_1.y == vec_2.y;
}
inline bool operator!=(ldtk::IntPoint vec_1, ldtk::IntPoint vec_2)
{
return !(vec_1.x == vec_2.x && vec_1.y == vec_2.y);
} |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Could you add some addition, subtraction, division, multiplication etc operators for structs like IntPoint?
Beta Was this translation helpful? Give feedback.
All reactions