Skip to content

Commit 5929d97

Browse files
committed
Add vector add/sub float operations
1 parent 3f02978 commit 5929d97

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

include/Vector2.hpp

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,29 @@ class Vector2 : public ::Vector2 {
6868
return *this;
6969
}
7070

71+
/**
72+
* Add vector and float value
73+
*/
74+
Vector2 Add(float add) const {
75+
return Vector2AddValue(*this, add);
76+
}
77+
78+
/**
79+
* Add vector and float value
80+
*/
81+
Vector2 operator+(float add) const {
82+
return Vector2AddValue(*this, add);
83+
}
84+
85+
/**
86+
* Add vector and float value
87+
*/
88+
Vector2& operator+=(float add) {
89+
set(Vector2AddValue(*this, add));
90+
91+
return *this;
92+
}
93+
7194
/**
7295
* Subtract two vectors (v1 - v2)
7396
*/
@@ -87,6 +110,29 @@ class Vector2 : public ::Vector2 {
87110
return *this;
88111
}
89112

113+
/**
114+
* Subtract vector by float value
115+
*/
116+
[[nodiscard]] Vector2 Subtract(float sub) const {
117+
return Vector2SubtractValue(*this, sub);
118+
}
119+
120+
/**
121+
* Subtract vector by float value
122+
*/
123+
Vector2 operator-(float sub) const {
124+
return Vector2SubtractValue(*this, sub);
125+
}
126+
127+
/**
128+
* Subtract vector by float value
129+
*/
130+
Vector2& operator-=(float sub) {
131+
set(Vector2SubtractValue(*this, sub));
132+
133+
return *this;
134+
}
135+
90136
/**
91137
* Negate vector
92138
*/

0 commit comments

Comments
 (0)