diff options
Diffstat (limited to 'dungeon/src/entity.rs')
| -rw-r--r-- | dungeon/src/entity.rs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/dungeon/src/entity.rs b/dungeon/src/entity.rs index f997b99..4ea6725 100644 --- a/dungeon/src/entity.rs +++ b/dungeon/src/entity.rs @@ -1,6 +1,6 @@ //! The `entity` module contains structures of all entities including players and enimies. -use crate::{Direction, Pos, const_pos}; +use crate::{Direction, FPos, Pos, const_pos}; /// The `Item` type represents any item an entity may be using #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] @@ -22,10 +22,12 @@ pub enum EntityKind { /// The `Entity` kind represents the main player, or any other /// ai autonomous character that can move freely across the /// dungeon. -#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] +#[derive(Clone, Copy, Debug, PartialEq)] pub struct Entity { /// The fixed grid position of the entity pub pos: Pos, + /// The floating (real) current position of the entity + pub fpos: FPos, /// Which direction this entity is facing pub dir: Direction, /// Which kind this entity is (along with entity kind specific data) @@ -54,8 +56,10 @@ impl Entity { kind: EntityKind, health: Option<u32>, ) -> Self { + let fpos = FPos::from_pos(pos); Self { pos, + fpos, dir, kind, health, @@ -82,7 +86,7 @@ impl Entity { } /// The `Player` type represents the main player entity -#[derive(Clone, Debug, PartialEq, Eq, Hash)] +#[derive(Clone, Debug, PartialEq)] pub struct Player { pub entity: Entity, pub inventory: Vec<Item>, |