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:
parent
eeeeffba53
commit
96525e24bf
|
@ -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.
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue