diff options
| author | troido <troido@protonmail.com> | 2020-02-03 20:16:09 +0100 |
|---|---|---|
| committer | troido <troido@protonmail.com> | 2020-02-03 20:16:09 +0100 |
| commit | 53f358f73c37e86f4db9e7bd7af309697dc7237e (patch) | |
| tree | d118cdfb10e1519995a92ac0c58db1051c41325d /src/components.rs | |
| parent | 30509956d4274b2565052dc045eec3742a159357 (diff) | |
only send changed cells, not the whole field each time
Diffstat (limited to 'src/components.rs')
| -rw-r--r-- | src/components.rs | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/src/components.rs b/src/components.rs index 3b17f0c..18de7f0 100644 --- a/src/components.rs +++ b/src/components.rs @@ -1,16 +1,38 @@ use specs::{ DenseVecStorage, + VecStorage, + FlaggedStorage, Component }; use super::controls::Control; +use super::pos::Pos; -#[derive(Component, Debug, Clone)] + +#[derive(Debug, Clone)] +pub struct Position{ + pub pos: Pos, + pub prev: Option<Pos> +} +impl Position { + pub fn new(pos: Pos) -> Position { + Position{pos, prev: None} + } +} + +impl Component for Position { + type Storage = FlaggedStorage<Self, VecStorage<Self>>; +} + +#[derive(Debug, Clone)] pub struct Visible { pub sprite: String, pub height: f32 } +impl Component for Visible { + type Storage = FlaggedStorage<Self, VecStorage<Self>>; +} #[derive(Component, Debug)] pub struct Controller(pub Control); @@ -20,5 +42,11 @@ pub struct Blocking; #[derive(Component, Debug)] pub struct Played { - pub name: String + pub name: String, + pub is_new: bool +} +impl Played { + pub fn new(name: String) -> Played { + Played{name, is_new: true} + } } |
