From 240ff459154f309b9b82b9c24fc4def184d359a3 Mon Sep 17 00:00:00 2001 From: talha Date: Fri, 25 Oct 2024 22:37:44 +0500 Subject: Added horizontal camera movement, some operator overloading --- source/math.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'source/math.h') 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) { -- cgit v1.2.3