From bfdaef7850b6ac17bb88f1b314236fb5014aac8e Mon Sep 17 00:00:00 2001 From: tom barrett Date: Fri, 5 Jul 2019 08:59:22 -0500 Subject: now a cells struct whichs layers own, which takes from tileset tiles --- src/layer.rs | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'src/layer.rs') diff --git a/src/layer.rs b/src/layer.rs index ef21059..2ae9dc2 100644 --- a/src/layer.rs +++ b/src/layer.rs @@ -1,41 +1,39 @@ use ggez::graphics::spritebatch::SpriteBatch; use crate::entity::Operable; -use crate::tile::Tile; +use crate::tile::Cell; use crate::tileset::Tileset; #[derive(Debug, Clone)] pub struct Layer { - pub tiles: Vec, - width: usize, - height: usize, + pub cells: Vec, + dimensions: (usize, usize), } impl Operable for Layer { fn update(&mut self) { - for tile in self.tiles.iter_mut() { - tile.update(); + for cell in self.cells.iter_mut() { + cell.update(); } } fn draw(&self, spritebatch: &mut SpriteBatch) { - for tile in self.tiles.iter() { - tile.draw(spritebatch); + for cell in self.cells.iter() { + cell.draw(spritebatch); } } } impl Layer { - pub fn new(text: &str, tileset: &Tileset, width: usize, height: usize) -> Layer { + pub fn new(text: &str, tileset: &Tileset, dimensions: (usize, usize)) -> Layer { Layer { - tiles: text + cells: text .replace("\n", "") .split(',') .enumerate() - .map(|(i, s)| Tile::new(s, i, tileset, width, height)) + .map(|(i, s)| Cell::new(s, i, tileset, dimensions)) .collect(), - width, - height, + dimensions, } } } -- cgit v1.2.3