diff options
| author | Freya Murphy <freya@freyacat.org> | 2025-10-23 13:08:40 -0400 |
|---|---|---|
| committer | Freya Murphy <freya@freyacat.org> | 2025-10-23 13:10:19 -0400 |
| commit | 0c3e9c8dc49ff11d7612bd7e0bc25030ae566ab1 (patch) | |
| tree | e286028ebb74c5ffd08433dd8ff25d6149b68afc /dungeon/src/entity.rs | |
| parent | Started implementing wfc crate into map (diff) | |
| download | DungeonCrawl-0c3e9c8dc49ff11d7612bd7e0bc25030ae566ab1.tar.gz DungeonCrawl-0c3e9c8dc49ff11d7612bd7e0bc25030ae566ab1.tar.bz2 DungeonCrawl-0c3e9c8dc49ff11d7612bd7e0bc25030ae566ab1.zip | |
dungeon: add FPos for decimial positions
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>, |