From ec2572f9e61cd3c7bfc4c446e45d23d7259567f2 Mon Sep 17 00:00:00 2001 From: nek0 Date: Sat, 10 Mar 2018 14:02:14 +0100 Subject: [PATCH] still working on collision --- src/Test.hs | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/Test.hs b/src/Test.hs index 159e32d..5943db7 100644 --- a/src/Test.hs +++ b/src/Test.hs @@ -163,9 +163,10 @@ updateMap dt = do -- ) concatMap (\(dr, dc) -> - let bs = imgObstacle - (imgMat (stateData ud) M.! - (floor (nr + dr), floor (nc + dc))) + let bs = fromMaybe [] (imgObstacle <$> (M.safeGet + (floor (nr + dr)) + (floor (nc + dc)) + (imgMat (stateData ud)))) in Prelude.map (\(Boundaries (minr, minc) (maxr, maxc))-> Boundaries (minr + dr, minc + dc) @@ -271,12 +272,13 @@ checkBoundsCollision -> V2 Double checkBoundsCollision (V2 pr pc) (V2 fr fc) (V2 mr mc) (Boundaries (minr, minc) (maxr, maxc)) - | ntestc && ntestr && not testc = V2 (1 * mr) (0 * mc) - | ntestr && ntestc && not testr = V2 (0 * mr) (1 * mc) - | not ntestr && not ntestc = V2 (1 * mr) (1 * mc) - | not ntestr && ntestc = V2 (1 * mr) (1 * mc) - | not ntestc && ntestr = V2 (1 * mr) (1 * mc) - | otherwise = V2 (0 * mr) (0 * mc) + | ntestc && ntestr && not testr && not testc = V2 (1 * mr) (1 * mc) + | ntestc && ntestr && not testc = V2 (1 * mr) (0 * mc) + | ntestr && ntestc && not testr = V2 (0 * mr) (1 * mc) + | not ntestr && not ntestc = V2 (1 * mr) (1 * mc) + | not ntestr && ntestc = V2 (1 * mr) (1 * mc) + | not ntestc && ntestr = V2 (1 * mr) (1 * mc) + | otherwise = V2 (0 * mr) (0 * mc) where ntestr | ndistr <= hheight + 0.15 = True