aboutsummaryrefslogtreecommitdiff
path: root/src/Game
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2023-05-28 22:41:24 +0100
committerJuan J. Martinez <jjm@usebox.net>2023-05-28 22:41:24 +0100
commitd0a454e0d5d33cfcb0b9ee851464a5d1274b0a12 (patch)
tree794f269ed81db7c1d2264faeb42a276e8050a433 /src/Game
parent41876fd5e296a967a5d2ad08e54a9f69651e083c (diff)
downloadspace-plat-hs-d0a454e0d5d33cfcb0b9ee851464a5d1274b0a12.tar.gz
space-plat-hs-d0a454e0d5d33cfcb0b9ee851464a5d1274b0a12.zip
Fix horizontal rendering for 16x16 tiles
It almost fixes vertical too, but there's an issue with the viewport.
Diffstat (limited to 'src/Game')
-rw-r--r--src/Game/Map.hs10
1 files changed, 5 insertions, 5 deletions
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]]