summaryrefslogtreecommitdiff
path: root/game_server/src/maths.rs
diff options
context:
space:
mode:
Diffstat (limited to 'game_server/src/maths.rs')
-rw-r--r--game_server/src/maths.rs23
1 files changed, 22 insertions, 1 deletions
diff --git a/game_server/src/maths.rs b/game_server/src/maths.rs
index cc6c777..7c4ee2f 100644
--- a/game_server/src/maths.rs
+++ b/game_server/src/maths.rs
@@ -53,11 +53,32 @@ impl std::ops::Mul<f32> for Vec2 {
fn mul(self, scale: f32) -> Self {
Self {
x: self.x * scale,
- y: -self.y * scale
+ y: self.y * scale
}
}
}
+impl std::ops::Div<f32> for Vec2 {
+ type Output = Self;
+ fn div(self, scale: f32) -> Self {
+ Self {
+ x: self.x / scale,
+ y: self.y / scale
+ }
+ }
+}
+
+impl std::ops::Div<Vec2> for Vec2 {
+ type Output = Self;
+ fn div(self, scale: Vec2) -> Self {
+ Self {
+ x: self.x / scale.x,
+ y: self.y / scale.y
+ }
+ }
+}
+
+
impl std::cmp::PartialOrd for Vec2 {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
if self.x <= other.x && self.y <= other.y {