stop walking animation when colliding
This commit is contained in:
parent
d99141dd82
commit
9c812f10d3
1 changed files with 22 additions and 21 deletions
43
src/Test.hs
43
src/Test.hs
|
@ -371,7 +371,7 @@ updateMap dt = do
|
||||||
aId = asId stat
|
aId = asId stat
|
||||||
nstat = case aiName aId of
|
nstat = case aiName aId of
|
||||||
"walking"
|
"walking"
|
||||||
| sqrt (vel' `dot` vel') > 0 ->
|
| sqrt (colldpos `dot` colldpos) > 0 ->
|
||||||
stat
|
stat
|
||||||
{ asId = aId
|
{ asId = aId
|
||||||
{ aiDirection = direction vel' rot'
|
{ aiDirection = direction vel' rot'
|
||||||
|
@ -386,7 +386,7 @@ updateMap dt = do
|
||||||
, asCurrentFrame = 0
|
, asCurrentFrame = 0
|
||||||
}
|
}
|
||||||
"standing"
|
"standing"
|
||||||
| sqrt (vel' `dot` vel') > 0 ->
|
| sqrt (colldpos `dot` colldpos) > 0 ->
|
||||||
stat
|
stat
|
||||||
{ asId = aId
|
{ asId = aId
|
||||||
{ aiDirection = direction vel' rot'
|
{ aiDirection = direction vel' rot'
|
||||||
|
@ -411,26 +411,27 @@ updateMap dt = do
|
||||||
if dpc < 0
|
if dpc < 0
|
||||||
then [(floor dpc :: Int) .. 0]
|
then [(floor dpc :: Int) .. 0]
|
||||||
else [0 .. (ceiling dpc :: Int)])
|
else [0 .. (ceiling dpc :: Int)])
|
||||||
ent = unchanged
|
colldpos = dpos * Prelude.foldl
|
||||||
{ pos = Set $ pos' + dpos * Prelude.foldl
|
(\acc a -> let ret = checkBoundsCollision2 pos' npos dt acc a
|
||||||
(\acc a -> let ret = checkBoundsCollision2 pos' npos dt acc a
|
in A.log A.Verbose (show ret) ret)
|
||||||
in A.log A.Verbose (show ret) ret)
|
(V2 1 1)
|
||||||
(V2 1 1)
|
(
|
||||||
(
|
concatMap
|
||||||
concatMap
|
(\(dr, dc) ->
|
||||||
(\(dr, dc) ->
|
let bs = fromMaybe [] (imgObstacle <$> (M.safeGet
|
||||||
let bs = fromMaybe [] (imgObstacle <$> (M.safeGet
|
(fromIntegral $ floor pr + dr)
|
||||||
(fromIntegral $ floor pr + dr)
|
(fromIntegral $ floor pc + dc)
|
||||||
(fromIntegral $ floor pc + dc)
|
(imgMat (stateData ud))))
|
||||||
(imgMat (stateData ud))))
|
in Prelude.map (\(Boundaries (minr, minc) (maxr, maxc))->
|
||||||
in Prelude.map (\(Boundaries (minr, minc) (maxr, maxc))->
|
Boundaries
|
||||||
Boundaries
|
(minr + fromIntegral dr, minc + fromIntegral dc)
|
||||||
(minr + fromIntegral dr, minc + fromIntegral dc)
|
(maxr + fromIntegral dr, maxc + fromIntegral dc)
|
||||||
(maxr + fromIntegral dr, maxc + fromIntegral dc)
|
) bs
|
||||||
) bs
|
)
|
||||||
)
|
lll -- (A.log A.Verbose (show lll ++ " " ++ show len) lll)
|
||||||
(A.log A.Verbose (show lll ++ " " ++ show len) lll)
|
|
||||||
)
|
)
|
||||||
|
ent = unchanged
|
||||||
|
{ pos = Set $ pos' + colldpos
|
||||||
, rot = Set (direction vel' rot')
|
, rot = Set (direction vel' rot')
|
||||||
, anim = Set nstat
|
, anim = Set nstat
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue