draw ordering

This commit is contained in:
nek0 2018-05-31 05:25:08 +02:00
parent d3e00e13ca
commit 98d7e610cb

View file

@ -189,20 +189,17 @@ drawTile ud ctx posanims pr pc row col img =
((realToFrac x :: Double) < 1280 && ((realToFrac x :: Double) < 1280 &&
(realToFrac (y - (74 - (realToFrac tileHeight :: CFloat))) :: Double) < 720)) $ (realToFrac (y - (74 - (realToFrac tileHeight :: CFloat))) :: Double) < 720)) $
do do
let lt = Prelude.filter (\(V2 nr nc, _) -> let lt = Prelude.filter delimiter sorted
(any (\m -> nr < fromIntegral (floor nr :: Int) + m) maxrs && ge = Prelude.filter (not . delimiter) sorted
any (\m -> nc > fromIntegral (floor nc :: Int) + m) maxcs)
) sorted
ge = Prelude.filter (\(V2 nr nc, _) -> not
(any (\m -> nr < fromIntegral (floor nr :: Int) + m) maxrs &&
any (\m -> nc > fromIntegral (floor nc :: Int) + m) maxcs)
) sorted
save ctx save ctx
mapM_ drawAnim lt mapM_ drawAnim lt
when (isJust img) drawImage when (isJust img) drawImage
mapM_ drawAnim ge mapM_ drawAnim ge
restore ctx restore ctx
where where
delimiter (V2 nr nc, _) =
(any (\m -> nr < fromIntegral (floor nr :: Int) + m) maxrs &&
any (\m -> nc > fromIntegral (floor nc :: Int) + m) mincs)
ai = assetImages ud ai = assetImages ud
anims = assetAnimations ud anims = assetAnimations ud
tileWidth = 64 :: Double tileWidth = 64 :: Double
@ -211,6 +208,7 @@ drawTile ud ctx posanims pr pc row col img =
(\(V2 ar ac, _) -> floor ar == row && floor ac == col) posanims (\(V2 ar ac, _) -> floor ar == row && floor ac == col) posanims
sorted = sortOn (\(V2 sr sc, _) -> sc + sr * maxCol) filtered sorted = sortOn (\(V2 sr sc, _) -> sc + sr * maxCol) filtered
maxCol = maximum (Prelude.map (\(V2 _ mc, _) -> mc) filtered) maxCol = maximum (Prelude.map (\(V2 _ mc, _) -> mc) filtered)
minrs = Prelude.map (fst . matmin) mb
maxrs = Prelude.map (fst . matmax) mb maxrs = Prelude.map (fst . matmax) mb
mincs = Prelude.map (snd . matmin) mb mincs = Prelude.map (snd . matmin) mb
maxcs = Prelude.map (snd . matmax) mb maxcs = Prelude.map (snd . matmax) mb