summaryrefslogtreecommitdiff
path: root/frontend/shared_cpp
diff options
context:
space:
mode:
authorMatthew Kosarek <mattkae@protonmail.com>2021-04-26 20:51:09 -0400
committerMatthew Kosarek <mattkae@protonmail.com>2021-04-26 20:51:09 -0400
commita32157049d860c4c9c6ffb0df6c3cdbf53e4ef1d (patch)
treefcdf2a06b07ef143f6615f71a6e26f3a1587b80d /frontend/shared_cpp
parentcdf770d6950befd25779a18ea3972deeb9f143bb (diff)
Getting started on rectangle collisions
Diffstat (limited to 'frontend/shared_cpp')
-rw-r--r--frontend/shared_cpp/mathlib.cpp11
-rw-r--r--frontend/shared_cpp/mathlib.h4
2 files changed, 15 insertions, 0 deletions
diff --git a/frontend/shared_cpp/mathlib.cpp b/frontend/shared_cpp/mathlib.cpp
new file mode 100644
index 0000000..8222d00
--- /dev/null
+++ b/frontend/shared_cpp/mathlib.cpp
@@ -0,0 +1,11 @@
+#include "mathlib.h"
+#include <cstdlib>
+
+Vector2 getRandomNormalVector2() {
+ Vector2 retval = {
+ static_cast<float>(rand()) / static_cast<float>(RAND_MAX),
+ static_cast<float>(rand()) / static_cast<float>(RAND_MAX)
+ };
+
+ return retval.normalize();
+}
diff --git a/frontend/shared_cpp/mathlib.h b/frontend/shared_cpp/mathlib.h
index a08ec39..3ed61cd 100644
--- a/frontend/shared_cpp/mathlib.h
+++ b/frontend/shared_cpp/mathlib.h
@@ -110,6 +110,10 @@ struct Vector4 {
float scale = 1.f / 255.f;
return { r * scale, g * scale, b * scale, a * scale };
}
+
+ Vector4 toNormalizedColor() {
+ return fromColor(x, y, z, w);
+ }
};
struct Mat4x4 {