diff options
Diffstat (limited to 'src/entity/player.rs')
-rw-r--r-- | src/entity/player.rs | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/entity/player.rs b/src/entity/player.rs index 45f3e13..e1961df 100644 --- a/src/entity/player.rs +++ b/src/entity/player.rs @@ -1,3 +1,4 @@ +use core::fmt; use std::{ collections::HashMap, fmt::{Display, Formatter}, @@ -7,8 +8,8 @@ use termion::event::Key; use crate::{ game::Command, - physics::{Point, Vector}, - Position, Render, Velocity, + physics::{Collidable, Collider, Point, Position, Vector, Velocity}, + Render, }; use crate::entity::Controllable; @@ -31,7 +32,7 @@ impl Player { } impl Display for Player { - fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result { + fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { return write!( f, "{}@", @@ -64,7 +65,7 @@ impl Position for Player { self.position } - fn set_position<P: Into<crate::physics::Point>>(&mut self, position: P) -> crate::Result<()> { + fn set_position<P: Into<Point>>(&mut self, position: P) -> crate::physics::Result<()> { self.position = position.into(); Ok(()) } @@ -75,8 +76,16 @@ impl Velocity for Player { self.velocity } - fn set_velocity<V: Into<crate::physics::Vector>>(&mut self, velocity: V) -> crate::Result<()> { + fn set_velocity<V: Into<Vector>>(&mut self, velocity: V) -> crate::physics::Result<()> { self.velocity = velocity.into(); Ok(()) } } + +impl Collider for Player { + fn collision_map(&self) -> &Vec<Point> { + &vec![self.position] + } +} + +impl Collidable for Player {} |