Entrance of a level
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user