Entrance of a level

This commit is contained in:
2018-10-06 21:28:26 +02:00
parent 5c54974159
commit 93d1678955
4 changed files with 27 additions and 2 deletions
+14
View File
@@ -274,6 +274,9 @@ impl Drawable for PositionedTile {
/// The map represents the tiles contained in a level.
pub struct Map {
/// The entrace point of the character in the map.
entrance: (usize, usize),
/// The tiles contained in the level.
tiles: Matrix<(CollisionTile, GraphicTile)>,
@@ -359,10 +362,21 @@ impl Map {
}
Map {
entrance: Map::find_entrance(&matrix),
tiles: matrix,
}
}
/// Finds a possible entrance.
pub fn find_entrance(tiles: &Matrix<(CollisionTile, GraphicTile)>) -> (usize, usize) {
(tiles.rows() - 5, 1)
}
/// Returns the entrance of the map.
pub fn entrance(&self) -> (usize, usize) {
self.entrance
}
/// Returns an iterator to the positioned tiles.
pub fn at(&self, row: usize, col: usize) -> PositionedTile {
PositionedTile {