Working on collisions

This commit is contained in:
2018-10-06 11:32:44 +02:00
parent a4b5a735ae
commit 89295b9283
8 changed files with 21 additions and 9 deletions
+6 -2
View File
@@ -234,6 +234,10 @@ impl Drawable for PositionedTile {
fn position(&self) -> Vector2<f32> {
self.position.into()
}
fn origin(&self) -> Vector2<f32> {
Vector2::new(0.0, 0.0)
}
}
/// The map represents the tiles contained in a level.
@@ -363,8 +367,8 @@ impl Map {
// Find tile on x, y
if x > 0.0 && y > 0.0 {
let row = (y / 16.0) as usize + 2;
let col = (x / 16.0) as usize + 1;
let row = (y / 16.0) as usize;
let col = (x / 16.0) as usize;
if let Some((tile, _)) = self.tiles.get((row, col)) {
if tile.from_top {