diff options
Diffstat (limited to 'game_server/src/maths.rs')
-rw-r--r-- | game_server/src/maths.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/game_server/src/maths.rs b/game_server/src/maths.rs index 7c4ee2f..b9303af 100644 --- a/game_server/src/maths.rs +++ b/game_server/src/maths.rs @@ -180,6 +180,18 @@ pub struct RBox { pub v2: Vec2, } +impl RBox { + pub fn new(pos: Vec2, orientation: Vec2, width: f32) -> Self { + let scale = width / orientation.distance(); + let orth = Vec2 {x: orientation.x / scale, y: -orientation.y / scale}; + Self { + pos: pos, + v1: orientation, + v2: orth, + } + } +} + impl std::ops::Add<Vec2> for RBox { type Output = Self; fn add(self, other: Vec2) -> Self { |