herkulesbug found. sticky walls

This commit is contained in:
nek0 2018-05-14 17:54:55 +02:00
parent 165baa179c
commit 4226265030

View file

@ -231,8 +231,8 @@ updateMap dt = do
concatMap
(\(dr, dc) ->
let bs = fromMaybe [] (imgObstacle <$> (M.safeGet
(fromIntegral $ floor nr + dr)
(fromIntegral $ floor nc + dc)
(fromIntegral $ floor pr + dr)
(fromIntegral $ floor pc + dc)
(imgMat (stateData ud))))
in Prelude.map (\(Boundaries (minr, minc) (maxr, maxc))->
Boundaries
@ -373,19 +373,19 @@ checkBoundsCollision2
-> V2 Double
checkBoundsCollision2
pre@(V2 pr pc) next@(V2 nr nc) dt acc (Boundaries (minr, minc) (maxr, maxc))
| (colltr < 0 && colltc < 0) || (inrow && incol) = A.log A.Debug ("both " ++ show (colltr, colltc)) (V2 0 0)
| colltr < 0 && incol = (A.log A.Debug ("row fixed " ++ show (colltr, colltc))(V2 0 1)) * acc
| colltc < 0 && inrow = (A.log A.Debug ("col fixed " ++ show (colltr, colltc))(V2 1 0)) * acc
| colltr < dt && colltc < dt = A.log A.Debug ("both " ++ show (colltr, colltc)) (V2 0 0)
| colltr < dt && incol = (A.log A.Debug ("row fixed " ++ show (colltr, colltc))(V2 0 1)) * acc
| colltc < dt && inrow = (A.log A.Debug ("col fixed " ++ show (colltr, colltc))(V2 1 0)) * acc
| otherwise = acc
where
vel@(V2 vr vc) = fmap (/ dt) (next - pre)
colltr
| vr > 0 = (((fromIntegral (floor nr :: Int)) + minr - 0.15) - nr) / vr
| vr < 0 = (((fromIntegral (floor nr :: Int)) + maxr + 0.15) - nr) / vr
| otherwise = 0
| vr > 0 = (((fromIntegral (floor pr :: Int)) + minr - 0.15) - pr) / vr
| vr < 0 = (((fromIntegral (floor pr :: Int)) + maxr + 0.15) - pr) / vr
| otherwise = dt
colltc
| vc > 0 = (((fromIntegral (floor nc :: Int)) + minc - 0.15) - nc) / vc
| vc < 0 = (((fromIntegral (floor nc :: Int)) + maxc + 0.15) - nc) / vc
| otherwise = 0
| vc > 0 = (((fromIntegral (floor pc :: Int)) + minc - 0.15) - pc) / vc
| vc < 0 = (((fromIntegral (floor pc :: Int)) + maxc + 0.15) - pc) / vc
| otherwise = dt
inrow = pr > minr && pr < maxr
incol = pc > minc && pc < maxc