From d0a454e0d5d33cfcb0b9ee851464a5d1274b0a12 Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Sun, 28 May 2023 22:41:24 +0100 Subject: Fix horizontal rendering for 16x16 tiles It almost fixes vertical too, but there's an issue with the viewport. --- src/Game/Map.hs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/Game') diff --git a/src/Game/Map.hs b/src/Game/Map.hs index d585ff6..8467989 100644 --- a/src/Game/Map.hs +++ b/src/Game/Map.hs @@ -304,7 +304,7 @@ render renderer (Map mapData tex (MapState _ step)) (Viewport vx vy vw vh) = do Vector.mapM_ ( \(x, y) -> -- clipping because we draw one extra row/col because the scroll - when (x < mapData.width && y < mapData.height) $ + when (x >= 0 && y >= 0 && x < mapData.width && y < mapData.height) $ renderTile x y (layer Vector.! (x + (y * mapData.width))) ) index @@ -316,12 +316,12 @@ render renderer (Map mapData tex (MapState _ step)) (Viewport vx vy vw vh) = do tileHeight = tileset.height -- origin x, y in tiles - ox = vx `div` tileWidth - oy = vy `div` tileHeight + ox = vx `div` tileWidth - 1 + oy = vy `div` tileHeight - 1 -- viewport size in tiles - drawWidth = vw `div` tileWidth - drawHeight = vh `div` tileHeight + drawWidth = 1 + vw `div` tileWidth + drawHeight = 1 + vh `div` tileHeight -- we draw one extra row/col index = Vector.fromList [(x, y) | x <- [ox .. ox + drawWidth], y <- [oy .. oy + drawHeight]] -- cgit v1.2.3