70 lines
1.5 KiB
C++
70 lines
1.5 KiB
C++
#include <raylib.h>
|
|
|
|
#define HALF_PI (PI / 2)
|
|
|
|
#define TAU (PI * 2)
|
|
|
|
#define V2_ZERO (Vector2){0.0f, 0.0f}
|
|
|
|
#define LENGTH_OF(a) ((sizeof(a) / sizeof(*(a))) / (size_t)(!(sizeof(a) % sizeof(*(a)))))
|
|
|
|
#define MAX(a, b) ((a > b) ? a : b)
|
|
|
|
#define MIN(a, b) ((a < b) ? a : b)
|
|
|
|
#define CLAMP(value, min, max) MIN(max, MAX(min, value))
|
|
|
|
#define SIGN(value) ((0 < value) - (value < 0))
|
|
|
|
typedef long unsigned Seed;
|
|
|
|
struct XorShifter {
|
|
Seed seed;
|
|
};
|
|
|
|
template<typename T> T const wrap(T const value, T const min, T const max) {
|
|
return ((value < min) ? max : (value > max) ? min : value);
|
|
}
|
|
|
|
Vector2 operator +(Vector2, Vector2);
|
|
|
|
Vector2 operator +=(Vector2&, Vector2);
|
|
|
|
Vector2 operator -(Vector2, Vector2);
|
|
|
|
Vector2 operator -=(Vector2&, Vector2);
|
|
|
|
Vector2 operator *(Vector2, Vector2);
|
|
|
|
Vector2 operator *=(Vector2&, Vector2);
|
|
|
|
Vector2 operator *(Vector2, float const);
|
|
|
|
Vector2 operator /(Vector2, Vector2);
|
|
|
|
Vector2 operator /=(Vector2&, Vector2);
|
|
|
|
Vector2 operator /(Vector2, float const);
|
|
|
|
bool operator <(Vector2, Vector2);
|
|
|
|
bool operator >(Vector2, Vector2);
|
|
|
|
float Vector2Distance(Vector2, Vector2);
|
|
|
|
float const LengthDirectionX(float const, float const);
|
|
|
|
float const LengthDirectionY(float const, float const);
|
|
|
|
Vector2 const LengthDirection(Vector2 const, float const);
|
|
|
|
float const AngleToPoint(Vector2 const, Vector2 const);
|
|
|
|
float const WrapAngle(float const);
|
|
|
|
float const AngleDifference(float const, float const);
|
|
|
|
XorShifter CreateXorShifter(Seed const);
|
|
|
|
long const GetXorShifterValue(XorShifter* const, long const, long const);
|