summaryrefslogtreecommitdiff
path: root/source/math.h
diff options
context:
space:
mode:
authortalha <sarcxd@gmail.com>2024-10-25 22:37:44 +0500
committertalha <sarcxd@gmail.com>2024-10-25 22:37:44 +0500
commit240ff459154f309b9b82b9c24fc4def184d359a3 (patch)
tree22c0eb2465f1020f7ad79cda010f4f9e315a3698 /source/math.h
parent1d51ae47889c1fd46af63a298b7d7ffd1e68ee54 (diff)
Added horizontal camera movement, some operator overloading
Diffstat (limited to 'source/math.h')
-rwxr-xr-xsource/math.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/source/math.h b/source/math.h
index 4f34cbc..3ecf6fb 100755
--- a/source/math.h
+++ b/source/math.h
@@ -65,6 +65,22 @@ union Vec2 {
return res;
}
+
+ Vec2 operator*(r32 scaler) const {
+ Vec2 res;
+ res.x = this->x * scaler;
+ res.y = this->y * scaler;
+
+ return res;
+ }
+
+ Vec2 operator*(const Vec2& v) const {
+ Vec2 res;
+ res.x = this->x * v.x;
+ res.y = this->y * v.y;
+
+ return res;
+ }
};
union Vec3 {
@@ -95,6 +111,13 @@ union Mat4 {
};
// ==== Vec2 ====
+Vec2 v2(r32 v) {
+ return Vec2{v, v};
+}
+
+Vec2 v2(r32 x, r32 y) {
+ return Vec2{x, y};
+}
r32 dot2v(Vec2 a, Vec2 b)
{