fix ghosting
This commit is contained in:
parent
70e6df88ca
commit
ccfc7aaac6
1 changed files with 16 additions and 11 deletions
27
src/Test.hs
27
src/Test.hs
|
@ -149,10 +149,13 @@ updateMap dt = do
|
||||||
pos'@(V2 or oc) <- E.get pos
|
pos'@(V2 or oc) <- E.get pos
|
||||||
vel' <- E.get vel
|
vel' <- E.get vel
|
||||||
let npos@(V2 nr nc) = pos' + fmap (* (4 * dt)) vel'
|
let npos@(V2 nr nc) = pos' + fmap (* (4 * dt)) vel'
|
||||||
let ent = defEntity'
|
dpos = npos - pos'
|
||||||
{ pos = Set $ Prelude.foldl (checkBoundsCollision pos')
|
ent = defEntity'
|
||||||
npos
|
{ pos = Set $ pos' + dpos * Prelude.foldl
|
||||||
(imgObstacle (imgMat (stateData ud) M.! (floor nr, floor nc)))
|
(checkBoundsCollision pos' npos)
|
||||||
|
(V2 1 1)
|
||||||
|
((imgObstacle (imgMat (stateData ud) M.! (floor nr, floor nc))) ++
|
||||||
|
(imgObstacle (imgMat (stateData ud) M.! (floor or, floor oc))))
|
||||||
}
|
}
|
||||||
return ent
|
return ent
|
||||||
putAffection ud
|
putAffection ud
|
||||||
|
@ -241,38 +244,40 @@ drawTile ai ctx pr pc row col img =
|
||||||
checkBoundsCollision
|
checkBoundsCollision
|
||||||
:: V2 Double
|
:: V2 Double
|
||||||
-> V2 Double
|
-> V2 Double
|
||||||
|
-> V2 Double
|
||||||
-> Boundaries Double
|
-> Boundaries Double
|
||||||
-> V2 Double
|
-> V2 Double
|
||||||
checkBoundsCollision
|
checkBoundsCollision
|
||||||
pos'@(V2 or oc) acc@(V2 fr fc) (Boundaries (minr, minc) (maxr, maxc))
|
pos@(V2 or oc) npos@(V2 fr fc) acc@(V2 mr mc)
|
||||||
|
(Boundaries (minr, minc) (maxr, maxc))
|
||||||
| (fr - fromIntegral (floor fr) >= minr &&
|
| (fr - fromIntegral (floor fr) >= minr &&
|
||||||
fr - fromIntegral (floor fr) <= maxr) &&
|
fr - fromIntegral (floor fr) <= maxr) &&
|
||||||
(fc - fromIntegral (floor fc) >= minc &&
|
(fc - fromIntegral (floor fc) >= minc &&
|
||||||
fc - fromIntegral (floor fc) <= maxc) &&
|
fc - fromIntegral (floor fc) <= maxc) &&
|
||||||
(or - fromIntegral (floor or) < minr ||
|
(or - fromIntegral (floor or) < minr ||
|
||||||
or - fromIntegral (floor or) > maxr) =
|
or - fromIntegral (floor or) > maxr) =
|
||||||
(V2 or fc)
|
(V2 (0 * mr) (1 * mc))
|
||||||
| (fr - fromIntegral (floor fr) >= minr &&
|
| (fr - fromIntegral (floor fr) >= minr &&
|
||||||
fr - fromIntegral (floor fr) <= maxr) &&
|
fr - fromIntegral (floor fr) <= maxr) &&
|
||||||
(fc - fromIntegral (floor fc) >= minc &&
|
(fc - fromIntegral (floor fc) >= minc &&
|
||||||
fc - fromIntegral (floor fc) <= maxc) &&
|
fc - fromIntegral (floor fc) <= maxc) &&
|
||||||
(oc - fromIntegral (floor oc) < minc ||
|
(oc - fromIntegral (floor oc) < minc ||
|
||||||
oc - fromIntegral (floor oc) > maxc) =
|
oc - fromIntegral (floor oc) > maxc) =
|
||||||
(V2 fr oc)
|
(V2 (1 * mr) (0 * mc))
|
||||||
| (fr - fromIntegral (floor fr) < minr ||
|
| (fr - fromIntegral (floor fr) < minr ||
|
||||||
fr - fromIntegral (floor fr) > maxr) &&
|
fr - fromIntegral (floor fr) > maxr) &&
|
||||||
(fc - fromIntegral (floor fc) < minc ||
|
(fc - fromIntegral (floor fc) < minc ||
|
||||||
fc - fromIntegral (floor fc) > maxc) =
|
fc - fromIntegral (floor fc) > maxc) =
|
||||||
acc
|
(V2 (1 * mr) (1 * mc))
|
||||||
| (fr - fromIntegral (floor fr) < minr ||
|
| (fr - fromIntegral (floor fr) < minr ||
|
||||||
fr - fromIntegral (floor fr) > maxr) &&
|
fr - fromIntegral (floor fr) > maxr) &&
|
||||||
(fc - fromIntegral (floor fc) >= minc &&
|
(fc - fromIntegral (floor fc) >= minc &&
|
||||||
fc - fromIntegral (floor fc) <= maxc) =
|
fc - fromIntegral (floor fc) <= maxc) =
|
||||||
acc
|
(V2 (1 * mr) (1 * mc))
|
||||||
| (fr - fromIntegral (floor fr) >= minr &&
|
| (fr - fromIntegral (floor fr) >= minr &&
|
||||||
fr - fromIntegral (floor fr) <= maxr) &&
|
fr - fromIntegral (floor fr) <= maxr) &&
|
||||||
(fc - fromIntegral (floor fc) < minc ||
|
(fc - fromIntegral (floor fc) < minc ||
|
||||||
fc - fromIntegral (floor fc) > maxc) =
|
fc - fromIntegral (floor fc) > maxc) =
|
||||||
acc
|
(V2 (1 * mr) (1 * mc))
|
||||||
| otherwise =
|
| otherwise =
|
||||||
pos'
|
(V2 (0 * mr) (0 * mc))
|
||||||
|
|
Loading…
Reference in a new issue