summaryrefslogtreecommitdiff
path: root/themes/mathlib.h
diff options
context:
space:
mode:
Diffstat (limited to 'themes/mathlib.h')
-rw-r--r--themes/mathlib.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/themes/mathlib.h b/themes/mathlib.h
index 99dfb62..82f85a2 100644
--- a/themes/mathlib.h
+++ b/themes/mathlib.h
@@ -21,6 +21,16 @@
#define DEG_TO_RAD(x) (x * (PI / 180.f))
#define RAD_TO_DEG(x) (x * (180.f / PI))
+// -- Random
+inline float randomFloatBetween(float min, float max) {
+ float random = static_cast<float>(rand()) / static_cast<float>(RAND_MAX);
+ return (max - min) * random + min;
+}
+
+inline int randomIntBetween(int min, int max) {
+ return static_cast<int>(randomFloatBetween(min, max));
+}
+
struct Vector2 {
float x = 0;
float y = 0;