From 274404b9eaf590960bb42fc4bd52e2263893fc8f Mon Sep 17 00:00:00 2001 From: Xevion Date: Fri, 8 Sep 2023 22:48:59 -0500 Subject: [PATCH] feat: entity trait, direction enum (util) --- src/direction.rs | 6 ++++++ src/entity.rs | 8 ++++++++ 2 files changed, 14 insertions(+) create mode 100644 src/direction.rs create mode 100644 src/entity.rs diff --git a/src/direction.rs b/src/direction.rs new file mode 100644 index 0000000..7f734d1 --- /dev/null +++ b/src/direction.rs @@ -0,0 +1,6 @@ +pub enum Direction { + Up, + Down, + Left, + Right, +} \ No newline at end of file diff --git a/src/entity.rs b/src/entity.rs new file mode 100644 index 0000000..ecd6007 --- /dev/null +++ b/src/entity.rs @@ -0,0 +1,8 @@ +pub trait Entity { + // Returns true if the entity is colliding with the other entity + fn is_colliding(&self, other: &dyn Entity) -> bool; + // Returns the absolute position of the entity + fn position(&self) -> (i32, i32); + // Returns the cell position of the entity (XY position within the grid) + fn cell_position(&self) -> (u32, u32); +} \ No newline at end of file