tinkering with collision
This commit is contained in:
parent
68c8464c9e
commit
eee9343313
1 changed files with 31 additions and 18 deletions
49
src/Test.hs
49
src/Test.hs
|
@ -152,15 +152,28 @@ updateMap dt = do
|
|||
{ pos = Set $ pos' + dpos * Prelude.foldl
|
||||
(checkBoundsCollision pos' npos)
|
||||
(V2 1 1)
|
||||
((imgObstacle (imgMat (stateData ud) M.! (floor nr, floor nc))) ++
|
||||
Prelude.map (\(Boundaries (minr, minc) (maxr, maxc)) ->
|
||||
let deltar = fromIntegral (floor pr - floor nr)
|
||||
deltac = fromIntegral (floor pc - floor nc)
|
||||
in Boundaries
|
||||
(minr + deltar, minc + deltac)
|
||||
(maxr + deltar, maxc + deltac)
|
||||
)
|
||||
(imgObstacle (imgMat (stateData ud) M.! (floor pr, floor pc))))
|
||||
(
|
||||
-- (imgObstacle (imgMat (stateData ud) M.! (floor nr, floor nc))) ++
|
||||
-- Prelude.map (\(Boundaries (minr, minc) (maxr, maxc)) ->
|
||||
-- let deltar = fromIntegral (floor pr - floor nr)
|
||||
-- deltac = fromIntegral (floor pc - floor nc)
|
||||
-- in Boundaries
|
||||
-- (minr + deltar, minc + deltac)
|
||||
-- (maxr + deltar, maxc + deltac)
|
||||
-- )
|
||||
concatMap
|
||||
(\(dr, dc) ->
|
||||
let bs = imgObstacle
|
||||
(imgMat (stateData ud) M.!
|
||||
(floor (nr + dr), floor (nc + dc)))
|
||||
in Prelude.map (\(Boundaries (minr, minc) (maxr, maxc))->
|
||||
Boundaries
|
||||
(minr + dr, minc + dc)
|
||||
(maxr + dr, maxc + dc)
|
||||
) bs
|
||||
)
|
||||
((,) <$> [-1..1] <*> [-1..1])
|
||||
)
|
||||
}
|
||||
return ent
|
||||
putAffection ud
|
||||
|
@ -258,28 +271,28 @@ checkBoundsCollision
|
|||
-> V2 Double
|
||||
checkBoundsCollision
|
||||
(V2 pr pc) (V2 fr fc) (V2 mr mc) (Boundaries (minr, minc) (maxr, maxc))
|
||||
| ntestr && ntestc && not testr = V2 (0 * 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.07 = True
|
||||
| ncdistsq <= 0.005 = True
|
||||
| ndistr <= hheight + 0.15 = True
|
||||
-- | ncdistsq <= 0.005 = True
|
||||
| otherwise = False
|
||||
ntestc
|
||||
| ndistc <= hwidth + 0.07 = True
|
||||
| ncdistsq <= 0.005 = True
|
||||
| ndistc <= hwidth + 0.15 = True
|
||||
-- | ncdistsq <= 0.005 = True
|
||||
| otherwise = False
|
||||
testr
|
||||
| distr <= hheight + 0.07 = True
|
||||
| cdistsq <= 0.005 = True
|
||||
| distr <= hheight + 0.15 = True
|
||||
-- | cdistsq <= 0.005 = True
|
||||
| otherwise = False
|
||||
testc
|
||||
| distc <= hwidth + 0.07 = True
|
||||
| cdistsq <= 0.005 = True
|
||||
| distc <= hwidth + 0.15 = 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)))
|
||||
|
|
Loading…
Reference in a new issue