Represent positions with i32 rather than usize

Even though we can now represent the three empty negative quadrants,
it'll make the math simpler to implement so I figure there's no reason
not to do it.
This commit is contained in:
Alex Bethel 2022-01-06 13:54:21 -06:00
parent eeeeffba53
commit 96525e24bf
2 changed files with 4 additions and 4 deletions

View file

@ -6,8 +6,8 @@ use specs_derive::Component;
/// Entities that have a physical position in the world.
#[derive(Component)]
pub struct Position {
pub x: usize,
pub y: usize,
pub x: i32,
pub y: i32,
}
/// Entities that need to be drawn as a single character.

View file

@ -37,8 +37,8 @@ impl<'a> System<'a> for MobSystem {
match mob.next_action {
MobAction::Nop => {}
MobAction::Move(dx, dy) => {
pos.x = (pos.x as i32 + dx) as _;
pos.y = (pos.y as i32 + dy) as _;
pos.x = pos.x + dx;
pos.y = pos.y + dy;
}
}