fixing ghost boundaries
This commit is contained in:
parent
4405539bd8
commit
146d65ce3b
1 changed files with 18 additions and 11 deletions
29
src/Test.hs
29
src/Test.hs
|
@ -153,7 +153,14 @@ updateMap dt = do
|
||||||
(checkBoundsCollision pos' npos)
|
(checkBoundsCollision pos' npos)
|
||||||
(V2 1 1)
|
(V2 1 1)
|
||||||
((imgObstacle (imgMat (stateData ud) M.! (floor nr, floor nc))) ++
|
((imgObstacle (imgMat (stateData ud) M.! (floor nr, floor nc))) ++
|
||||||
(imgObstacle (imgMat (stateData ud) M.! (floor pr, floor pc))))
|
Prelude.map (\(Boundaries (minr, minc) (maxr, maxc)) ->
|
||||||
|
let deltar = fromIntegral (floor nr - floor pr)
|
||||||
|
deltac = fromIntegral (floor nc - floor pc)
|
||||||
|
in Boundaries
|
||||||
|
(minr + deltar, minc + deltac)
|
||||||
|
(maxr + deltar, maxc + deltac)
|
||||||
|
)
|
||||||
|
(imgObstacle (imgMat (stateData ud) M.! (floor pr, floor pc))))
|
||||||
}
|
}
|
||||||
return ent
|
return ent
|
||||||
putAffection ud
|
putAffection ud
|
||||||
|
@ -180,8 +187,8 @@ drawTile ai ctx pr pc row col img =
|
||||||
drawImage
|
drawImage
|
||||||
drawPlayer
|
drawPlayer
|
||||||
else do
|
else do
|
||||||
if any (\maxr -> pr <= (fromIntegral (floor pr :: Int)) + maxr) maxrs &&
|
if all (\maxr -> pr <= (fromIntegral (floor pr :: Int)) + maxr) maxrs &&
|
||||||
any (\minc -> pc >= (fromIntegral (floor pc :: Int)) + minc) mincs
|
all (\minc -> pc >= (fromIntegral (floor pc :: Int)) + minc) mincs
|
||||||
then do
|
then do
|
||||||
drawPlayer
|
drawPlayer
|
||||||
drawImage
|
drawImage
|
||||||
|
@ -256,24 +263,24 @@ checkBoundsCollision
|
||||||
where
|
where
|
||||||
ntestr
|
ntestr
|
||||||
| ndistr <= hheight + 0.07 = True
|
| ndistr <= hheight + 0.07 = True
|
||||||
| ncdistsq <= 0.005 = True
|
-- | ncdistsq <= 0.005 = True
|
||||||
| otherwise = False
|
| otherwise = False
|
||||||
ntestc
|
ntestc
|
||||||
| ndistc <= hwidth + 0.07 = True
|
| ndistc <= hwidth + 0.07 = True
|
||||||
| ncdistsq <= 0.005 = True
|
-- | ncdistsq <= 0.005 = True
|
||||||
| otherwise = False
|
| otherwise = False
|
||||||
testr
|
testr
|
||||||
| distr <= hheight + 0.07 = True
|
| distr <= hheight + 0.07 = True
|
||||||
| cdistsq <= 0.005 = True
|
-- | cdistsq <= 0.005 = True
|
||||||
| otherwise = False
|
| otherwise = False
|
||||||
testc
|
testc
|
||||||
| distc <= hwidth + 0.07 = True
|
| distc <= hwidth + 0.07 = 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)))
|
||||||
distr = abs ((pr - fromIntegral (floor pr :: Int)) - (minr + hheight))
|
distr = abs (pr - (fromIntegral (floor fr :: Int) + (minr + hheight)))
|
||||||
distc = abs ((pc - fromIntegral (floor pc :: Int)) - (minc + hwidth))
|
distc = abs (pc - (fromIntegral (floor fc :: Int) + (minc + hwidth)))
|
||||||
hheight = (maxr - minr) / 2
|
hheight = (maxr - minr) / 2
|
||||||
hwidth = (maxc - minc) / 2
|
hwidth = (maxc - minc) / 2
|
||||||
ncdistsq = (ndistr - hheight) ^ (2 :: Int) + (ndistc - hwidth) ^ (2 :: Int)
|
ncdistsq = (ndistr - hheight) ^ (2 :: Int) + (ndistc - hwidth) ^ (2 :: Int)
|
||||||
|
|
Loading…
Reference in a new issue