From 96525e24bfcbb48fb53ba094b9ae9c6ca9b3bee4 Mon Sep 17 00:00:00 2001 From: Alex Bethel Date: Thu, 6 Jan 2022 13:54:21 -0600 Subject: [PATCH] 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. --- src/components.rs | 4 ++-- src/systems.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components.rs b/src/components.rs index 0111027..0b7f39a 100644 --- a/src/components.rs +++ b/src/components.rs @@ -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. diff --git a/src/systems.rs b/src/systems.rs index 7c4d804..c02e2ce 100644 --- a/src/systems.rs +++ b/src/systems.rs @@ -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; } }