still working on collision

This commit is contained in:
nek0 2018-03-10 14:02:14 +01:00
parent eee9343313
commit ec2572f9e6

View file

@ -163,9 +163,10 @@ updateMap dt = do
-- ) -- )
concatMap concatMap
(\(dr, dc) -> (\(dr, dc) ->
let bs = imgObstacle let bs = fromMaybe [] (imgObstacle <$> (M.safeGet
(imgMat (stateData ud) M.! (floor (nr + dr))
(floor (nr + dr), floor (nc + dc))) (floor (nc + dc))
(imgMat (stateData ud))))
in Prelude.map (\(Boundaries (minr, minc) (maxr, maxc))-> in Prelude.map (\(Boundaries (minr, minc) (maxr, maxc))->
Boundaries Boundaries
(minr + dr, minc + dc) (minr + dr, minc + dc)
@ -271,12 +272,13 @@ checkBoundsCollision
-> V2 Double -> V2 Double
checkBoundsCollision checkBoundsCollision
(V2 pr pc) (V2 fr fc) (V2 mr mc) (Boundaries (minr, minc) (maxr, maxc)) (V2 pr pc) (V2 fr fc) (V2 mr mc) (Boundaries (minr, minc) (maxr, maxc))
| ntestc && ntestr && not testc = V2 (1 * mr) (0 * mc) | ntestc && ntestr && not testr && not testc = V2 (1 * mr) (1 * mc)
| ntestr && ntestc && not testr = V2 (0 * mr) (1 * mc) | ntestc && ntestr && not testc = V2 (1 * mr) (0 * mc)
| not ntestr && not ntestc = V2 (1 * mr) (1 * mc) | ntestr && ntestc && not testr = V2 (0 * mr) (1 * mc)
| not ntestr && ntestc = V2 (1 * mr) (1 * mc) | not ntestr && not ntestc = V2 (1 * mr) (1 * mc)
| not ntestc && ntestr = V2 (1 * mr) (1 * mc) | not ntestr && ntestc = V2 (1 * mr) (1 * mc)
| otherwise = V2 (0 * mr) (0 * mc) | not ntestc && ntestr = V2 (1 * mr) (1 * mc)
| otherwise = V2 (0 * mr) (0 * mc)
where where
ntestr ntestr
| ndistr <= hheight + 0.15 = True | ndistr <= hheight + 0.15 = True