summaryrefslogtreecommitdiff
path: root/src/layer.rs
diff options
context:
space:
mode:
authortom barrett <spalf0@gmail.com>2019-07-05 08:59:22 -0500
committertom barrett <spalf0@gmail.com>2019-07-05 08:59:22 -0500
commitbfdaef7850b6ac17bb88f1b314236fb5014aac8e (patch)
tree748ceca98138b5783655ec181ea905a25a690934 /src/layer.rs
parent6589e5e3df63d5abf85313c4d21097432257f453 (diff)
now a cells struct whichs layers own, which takes from tileset tiles
Diffstat (limited to 'src/layer.rs')
-rw-r--r--src/layer.rs24
1 files changed, 11 insertions, 13 deletions
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<Tile>,
- width: usize,
- height: usize,
+ pub cells: Vec<Cell>,
+ 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,
}
}
}