From b79c50b491d7864a4578a4f0ad44cca261af80f6 Mon Sep 17 00:00:00 2001 From: nek0 Date: Thu, 8 Mar 2018 17:23:14 +0100 Subject: [PATCH] fix it! --- src/Test.hs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/Test.hs b/src/Test.hs index 9933ef5..fc52d3c 100644 --- a/src/Test.hs +++ b/src/Test.hs @@ -187,14 +187,16 @@ drawTile ai ctx pr pc row col img = drawImage drawPlayer else do - if any (\minr -> pr <= (fromIntegral (floor pr :: Int)) + minr) maxrs && - any (\maxc -> pc >= (fromIntegral (floor pc :: Int)) + maxc) mincs + if (all (\m -> pr > (fromIntegral (floor pr :: Int)) + m) minrs && + all (\m -> pc < (fromIntegral (floor pc :: Int)) + m) mincs) || + (all (\m -> pr > (fromIntegral (floor pr :: Int)) + m) minrs && + all (\m -> pc < (fromIntegral (floor pc :: Int)) + m) maxcs) then do - drawPlayer drawImage + drawPlayer else do - drawImage drawPlayer + drawImage restore ctx where tileWidth = 64 :: Double @@ -263,19 +265,19 @@ checkBoundsCollision where ntestr | ndistr <= hheight + 0.07 = True - -- | ncdistsq <= 0.005 = True + | ncdistsq <= 0.005 = True | otherwise = False ntestc | ndistc <= hwidth + 0.07 = True - -- | ncdistsq <= 0.005 = True + | ncdistsq <= 0.005 = True | otherwise = False testr | distr <= hheight + 0.07 = True - -- | cdistsq <= 0.005 = True + | cdistsq <= 0.005 = True | otherwise = False testc | distc <= hwidth + 0.07 = True - -- | cdistsq <= 0.005 = True + | cdistsq <= 0.005 = True | otherwise = False ndistr = abs (fr - (fromIntegral (floor fr :: Int) + (minr + hheight))) ndistc = abs (fc - (fromIntegral (floor fc :: Int) + (minc + hwidth)))