make vec2 make more sense

This commit is contained in:
Isse 2023-12-12 19:25:06 +01:00
parent 57bf7cfdac
commit 5361b290df
2 changed files with 5 additions and 3 deletions

View File

@ -1390,7 +1390,7 @@ impl Structure for Tavern {
},
(true, true) => {
painter.sprite(
dir.vec2(edge, rot_edge).with_z(room.bounds.min.z),
dir.abs().vec2(edge, rot_edge).with_z(room.bounds.min.z),
SpriteKind::CookingPot,
);
},

View File

@ -110,12 +110,14 @@ impl Dir {
}
}
/// Create a vec2 where x is in the direction of `self`, and y is anti
/// clockwise of `self`.
pub fn vec2(self, x: i32, y: i32) -> Vec2<i32> {
match self {
Dir::X => Vec2::new(x, y),
Dir::NegX => Vec2::new(x, y),
Dir::NegX => Vec2::new(-x, -y),
Dir::Y => Vec2::new(y, x),
Dir::NegY => Vec2::new(y, x),
Dir::NegY => Vec2::new(-y, -x),
}
}