diff options
Diffstat (limited to 'renderer/src/map.rs')
-rw-r--r-- | renderer/src/map.rs | 52 |
1 files changed, 14 insertions, 38 deletions
diff --git a/renderer/src/map.rs b/renderer/src/map.rs index 8517ee0..f687809 100644 --- a/renderer/src/map.rs +++ b/renderer/src/map.rs @@ -13,6 +13,8 @@ pub struct MapRenderer { tileset: HashMap<Option<usize>, Image>, } +const TILE_SIZE: f32 = 32.0; + impl MapRenderer { pub fn new() -> Self { Self { @@ -63,14 +65,14 @@ impl MapRenderer { let center = world .local_tee() - .map(|t| (t.x / 16, t.y / 16)) + .map(|t| (t.x / 32, t.y / 32)) .unwrap_or((0, 0)); let tile_rect = Rect { - top: center.1 as f32 * 16.0, - left: center.0 as f32 * 16.0, - bottom: center.1 as f32 * 16.0 + 16.0, - right: center.0 as f32 * 16.0 + 16.0, + top: center.1 as f32 * TILE_SIZE, + left: center.0 as f32 * TILE_SIZE, + bottom: center.1 as f32 * TILE_SIZE + TILE_SIZE, + right: center.0 as f32 * TILE_SIZE + TILE_SIZE, }; canvas.draw_rect(tile_rect, &grid_paint); @@ -85,6 +87,8 @@ impl MapRenderer { if tileset.dim() == (1, 1) { continue; } + + // let magic = (186, 50); // println!("{:?} {:?}", center, l.tiles.dim()); for layer_y in (center.1 - 15)..(center.1 + 15) { for layer_x in (center.0 - 15)..(center.0 + 15) { @@ -92,10 +96,10 @@ impl MapRenderer { let layer_y = layer_y.try_into().unwrap_or(0); let tile_rect = Rect { - top: layer_y as f32 * 16.0, - left: layer_x as f32 * 16.0, - bottom: layer_y as f32 * 16.0 + 16.0, - right: layer_x as f32 * 16.0 + 16.0, + top: layer_y as f32 * TILE_SIZE, + left: layer_x as f32 * TILE_SIZE, + bottom: layer_y as f32 * TILE_SIZE + TILE_SIZE, + right: layer_x as f32 * TILE_SIZE + TILE_SIZE, }; canvas.draw_rect(tile_rect, &grid_paint); @@ -103,7 +107,6 @@ impl MapRenderer { Some(t) => t, None => continue, }; - println!("{:?}", tile); let _rotate = tile.flags & format::TILEFLAG_ROTATE != 0; let _vflip = tile.flags & format::TILEFLAG_VFLIP != 0; @@ -115,7 +118,7 @@ impl MapRenderer { continue; } - const TL: u32 = 16; + const TL: u32 = 64; canvas.draw_image_rect( self.tileset.get(&l.image).unwrap(), Some(( @@ -130,33 +133,6 @@ impl MapRenderer { tile_rect, &Paint::default(), ); - // for iy in 0..TL { - // for ix in 0..TL { - // let (x, y) = ((layer_x as u32 * TL + iy), (layer_y as u32 * TL + ix)); - // let p_tile = - // tileset[((tile_y * TL + iy) as usize, (tile_x * TL + ix) as usize)]; - // let mut p = Paint::new( - // Color4f { - // a: 0.0, - // b: 0.0, - // g: 0.0, - // r: 0.0, - // }, - // &ColorSpace::new_srgb(), - // ); - // p.set_argb(p_tile.alpha, p_tile.red, p_tile.green, p_tile.green); - // p.set_style(PaintStyle::Fill); - // canvas.draw_rect( - // Rect { - // left: x as f32, - // top: y as f32, - // right: x as f32 + 1.0, - // bottom: y as f32 + 1.0, - // }, - // &p, - // ); - // } - // } } } } |