diff options
author | talha <sarcxd@gmail.com> | 2025-01-15 14:26:29 +0500 |
---|---|---|
committer | talha <sarcxd@gmail.com> | 2025-01-15 14:26:29 +0500 |
commit | d718dc1cfc04f1eabce48159f258a7f2dc281fc3 (patch) | |
tree | bd611715982f37bc22811cfde4ad508d69dbec6f /source/math.h | |
parent | 7d26a3cc6cfd9c207693ef977b0f0922d52e1d5c (diff) |
Added IVec, setting up level editing
Diffstat (limited to 'source/math.h')
-rwxr-xr-x | source/math.h | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/source/math.h b/source/math.h index 3f20e43..1d0ebc2 100755 --- a/source/math.h +++ b/source/math.h @@ -33,6 +33,71 @@ r32 clampf(r32 x, r32 bottom, r32 top) // ==== Vector Math ==== +union IVec2 { + struct { + u32 x; + u32 y; + }; + u32 data[2]; + + IVec2 operator+(u32 scaler) { + IVec2 res; + res.x = this->x + scaler; + res.y = this->y + scaler; + + return res; + } + + IVec2 operator+(IVec2 v) { + IVec2 res; + res.x = this->x + v.x; + res.y = this->y + v.y; + + return res; + } + + IVec2 operator-(u32 scaler) { + IVec2 res; + res.x = this->x - scaler; + res.y = this->y - scaler; + + return res; + } + + IVec2 operator-(IVec2 v) { + IVec2 res; + res.x = this->x - v.x; + res.y = this->y - v.y; + + return res; + } + + IVec2 operator*(u32 scaler) { + IVec2 res; + res.x = this->x * scaler; + res.y = this->y * scaler; + + return res; + } + + IVec2 operator*(IVec2 v) { + IVec2 res; + res.x = this->x * v.x; + res.y = this->y * v.y; + + return res; + } + + IVec2 operator/(u32 scaler) { + SDL_assert(scaler != 0); + IVec2 res; + res.x = this->x / scaler; + res.y = this->y / scaler; + + return res; + } +}; + union Vec2 { struct { r32 x; |