Working on the editor

This commit is contained in:
2019-03-30 12:53:29 +01:00
parent e539fe402e
commit ae601720e3
2 changed files with 44 additions and 4 deletions
+22
View File
@@ -109,6 +109,18 @@ pub enum GraphicTile {
}
impl GraphicTile {
/// Returns a graphic tile from a collision tile.
///
/// This might be ugly for the moment.
pub fn from_collision_tile(collision: CollisionTile) -> GraphicTile {
if collision == CollisionTile::empty() {
GraphicTile::Hidden
} else {
GraphicTile::Center
}
}
/// Checks if a graphic tile has a top border.
pub fn is_top(self) -> bool {
match self {
@@ -343,6 +355,16 @@ impl Map {
}
}
/// Returns a tile of the map.
pub fn tile(&self, i: usize, j: usize) -> CollisionTile {
self.tiles[(i, j)].0
}
/// Changes a tile of the map.
pub fn set_tile(&mut self, i: usize, j: usize, tile: CollisionTile) {
self.tiles[(i, j)] = (tile, GraphicTile::from_collision_tile(tile));
}
/// Finds a possible entrance.
pub fn find_entrance(tiles: &Matrix<(CollisionTile, GraphicTile)>) -> (usize, usize) {
(tiles.rows() - 5, 1)