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)))