summaryrefslogtreecommitdiff
path: root/game_server/src/maths.rs
diff options
context:
space:
mode:
authorDennis Kobert <d-kobert@web.de>2019-06-02 13:57:54 +0200
committerDennis Kobert <d-kobert@web.de>2019-06-02 13:57:54 +0200
commit7d0f3cf2bec7a248aed699805542ad235e354753 (patch)
tree580166a6bd5214d78a3fea57caf269be11cf06a4 /game_server/src/maths.rs
parentee573fd1a02d290ec2aa9201d923805b6d998b14 (diff)
Fix rotated hitbox point interaction
implement according tests
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 {