diff options
author | talha <sarcxd@gmail.com> | 2024-10-25 22:37:44 +0500 |
---|---|---|
committer | talha <sarcxd@gmail.com> | 2024-10-25 22:37:44 +0500 |
commit | 240ff459154f309b9b82b9c24fc4def184d359a3 (patch) | |
tree | 22c0eb2465f1020f7ad79cda010f4f9e315a3698 /source/math.h | |
parent | 1d51ae47889c1fd46af63a298b7d7ffd1e68ee54 (diff) |
Added horizontal camera movement, some operator overloading
Diffstat (limited to 'source/math.h')
-rwxr-xr-x | source/math.h | 23 |
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) { |