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
|
{ pos = Set $ pos' + dpos * Prelude.foldl
|
||||||
(checkBoundsCollision pos' npos)
|
(checkBoundsCollision pos' npos)
|
||||||
(V2 1 1)
|
(V2 1 1)
|
||||||
((imgObstacle (imgMat (stateData ud) M.! (floor nr, floor nc))) ++
|
(
|
||||||
Prelude.map (\(Boundaries (minr, minc) (maxr, maxc)) ->
|
-- (imgObstacle (imgMat (stateData ud) M.! (floor nr, floor nc))) ++
|
||||||
let deltar = fromIntegral (floor pr - floor nr)
|
-- Prelude.map (\(Boundaries (minr, minc) (maxr, maxc)) ->
|
||||||
deltac = fromIntegral (floor pc - floor nc)
|
-- let deltar = fromIntegral (floor pr - floor nr)
|
||||||
in Boundaries
|
-- deltac = fromIntegral (floor pc - floor nc)
|
||||||
(minr + deltar, minc + deltac)
|
-- in Boundaries
|
||||||
(maxr + deltar, maxc + deltac)
|
-- (minr + deltar, minc + deltac)
|
||||||
)
|
-- (maxr + deltar, maxc + deltac)
|
||||||
(imgObstacle (imgMat (stateData ud) M.! (floor pr, floor pc))))
|
-- )
|
||||||
|
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
|
return ent
|
||||||
putAffection ud
|
putAffection ud
|
||||||
|
@ -258,28 +271,28 @@ 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))
|
||||||
| ntestr && ntestc && not testr = V2 (0 * mr) (1 * mc)
|
|
||||||
| ntestc && ntestr && not testc = V2 (1 * mr) (0 * 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 && not ntestc = V2 (1 * mr) (1 * mc)
|
||||||
| not ntestr && ntestc = V2 (1 * mr) (1 * mc)
|
| not ntestr && ntestc = V2 (1 * mr) (1 * mc)
|
||||||
| not ntestc && ntestr = V2 (1 * mr) (1 * mc)
|
| not ntestc && ntestr = V2 (1 * mr) (1 * mc)
|
||||||
| otherwise = V2 (0 * mr) (0 * mc)
|
| otherwise = V2 (0 * mr) (0 * mc)
|
||||||
where
|
where
|
||||||
ntestr
|
ntestr
|
||||||
| ndistr <= hheight + 0.07 = True
|
| ndistr <= hheight + 0.15 = True
|
||||||
| ncdistsq <= 0.005 = True
|
-- | ncdistsq <= 0.005 = True
|
||||||
| otherwise = False
|
| otherwise = False
|
||||||
ntestc
|
ntestc
|
||||||
| ndistc <= hwidth + 0.07 = True
|
| ndistc <= hwidth + 0.15 = True
|
||||||
| ncdistsq <= 0.005 = True
|
-- | ncdistsq <= 0.005 = True
|
||||||
| otherwise = False
|
| otherwise = False
|
||||||
testr
|
testr
|
||||||
| distr <= hheight + 0.07 = True
|
| distr <= hheight + 0.15 = True
|
||||||
| cdistsq <= 0.005 = True
|
-- | cdistsq <= 0.005 = True
|
||||||
| otherwise = False
|
| otherwise = False
|
||||||
testc
|
testc
|
||||||
| distc <= hwidth + 0.07 = True
|
| distc <= hwidth + 0.15 = True
|
||||||
| cdistsq <= 0.005 = True
|
-- | cdistsq <= 0.005 = True
|
||||||
| otherwise = False
|
| otherwise = False
|
||||||
ndistr = abs (fr - (fromIntegral (floor fr :: Int) + (minr + hheight)))
|
ndistr = abs (fr - (fromIntegral (floor fr :: Int) + (minr + hheight)))
|
||||||
ndistc = abs (fc - (fromIntegral (floor fc :: Int) + (minc + hwidth)))
|
ndistc = abs (fc - (fromIntegral (floor fc :: Int) + (minc + hwidth)))
|
||||||
|
|
Loading…
Add table
Reference in a new issue