mirror of
https://git.sr.ht/~magic_rb/haskell-games
synced 2024-11-25 09:36:13 +01:00
Replace forM
in physics with cmap
Signed-off-by: magic_rb <richard@brezak.sk>
This commit is contained in:
parent
5d53c2aa90
commit
e5f10c6e34
|
@ -172,13 +172,13 @@ applyVelocity'' = do
|
||||||
fractions' = filter (not . isNaN . (^. _2)) clampedFractions
|
fractions' = filter (not . isNaN . (^. _2)) clampedFractions
|
||||||
(info, minTime) = minimumBy order ((Nothing, remainingTime) : fractions')
|
(info, minTime) = minimumBy order ((Nothing, remainingTime) : fractions')
|
||||||
|
|
||||||
forM_ allEntities \entity1 -> do
|
AE.cmap @w @(PositionComponent, AABBComponent, Maybe BodyComponent, Maybe VelocityComponent) @PositionComponent \(position1, _, body1, velocity1) ->
|
||||||
(position1, velocity1, body1) <- AE.get @w @(PositionComponent, Maybe VelocityComponent, Maybe BodyComponent) entity1
|
|
||||||
let
|
let
|
||||||
velocity1' = fromMaybe (Velocity $ pure 0) velocity1
|
velocity1' = fromMaybe (Velocity $ pure 0) velocity1
|
||||||
|
in
|
||||||
unless (unVelocity velocity1' == pure 0 || maybe False (^. immovable) body1) $
|
if unVelocity velocity1' == pure 0 || maybe False (^. immovable) body1
|
||||||
AE.set @w entity1 (Position $ position1.position + unVelocity velocity1' * pure (clampDown minTime))
|
then position1
|
||||||
|
else Position $ position1.position + unVelocity velocity1' * pure (clampDown minTime)
|
||||||
case info of
|
case info of
|
||||||
Just ((entityA, positionA, velocityA, aabbA, bodyA), (entityB, positionB, velocityB, aabbB, bodyB)) -> do
|
Just ((entityA, positionA, velocityA, aabbA, bodyA), (entityB, positionB, velocityB, aabbB, bodyB)) -> do
|
||||||
do
|
do
|
||||||
|
|
Loading…
Reference in a new issue