clean up tile rendering

This commit is contained in:
Crispy 2024-10-05 15:18:41 +02:00
parent 86548a8b0d
commit 5a23dde43a
5 changed files with 14 additions and 35 deletions

View file

@ -101,7 +101,14 @@ impl Board {
if let Some(tile) = self.get((x, y).into()) {
let px = x as i32 * tile_size + offset.x as i32 + tile_size / 2;
let py = y as i32 * tile_size + offset.y as i32 + tile_size / 2;
tile.draw(d, textures, px, py, tile_size, zoom);
let texture = textures.get(&tile.texture()).unwrap_or_else(||textures.get("missing").unwrap());
d.draw_texture_ex(
texture,
Vector2::new((px - tile_size / 2) as f32, (py - tile_size / 2) as f32),
0.0,
(1 << zoom) as f32,
Color::WHITE,
);
}
}
}