basic tile drawing
This commit is contained in:
parent
1257388168
commit
a0f11b60fb
3 changed files with 43 additions and 5 deletions
|
@ -18,6 +18,15 @@ impl From<(usize, usize)> for Pos {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<Vector2> for Pos {
|
||||
fn from(vec: Vector2) -> Self {
|
||||
Self {
|
||||
x: vec.x as isize,
|
||||
y: vec.y as isize,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Board {
|
||||
rows: Vec<Vec<Tile>>,
|
||||
|
@ -101,7 +110,9 @@ 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;
|
||||
let texture = textures.get(&tile.texture()).unwrap_or_else(||textures.get("missing").unwrap());
|
||||
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),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue