try making objects move
This commit is contained in:
parent
25b6eb659d
commit
40e82e26f6
3 changed files with 48 additions and 41 deletions
|
@ -147,6 +147,8 @@ class (Show c, Mass c) => Collidible c where
|
|||
NoCollision
|
||||
(_, _, True, _, _) ->
|
||||
A.log A.Debug ("CORNER CASE!") NoCollision
|
||||
(False, False, _, _, _) ->
|
||||
NoCollision
|
||||
x -> error $
|
||||
"Unhandled combination of collision check results: "
|
||||
<> (fromString $ show x)
|
||||
|
|
|
@ -33,8 +33,10 @@ update level dt = liftIO $ do
|
|||
atomically $ do
|
||||
lmap <- readTMVar (testMap level)
|
||||
let layer = mapLayers lmap V.! fromIntegral (mapWalkLayer lmap)
|
||||
modifyTVar
|
||||
(testCast level) $ \cast ->
|
||||
oldCast <- V.map (\(Cast c) -> Cast $ perform dt c) <$>
|
||||
readTVar (testCast level)
|
||||
oldCat <- perform dt <$> fromJust <$> readTVar (testPlayer level)
|
||||
modifyTVar (testCast level) $ \cast ->
|
||||
let playedCast =
|
||||
V.map
|
||||
(\(Cast c) -> Cast (perform dt c))
|
||||
|
@ -66,14 +68,17 @@ update level dt = liftIO $ do
|
|||
Cast $ performWorldCollision c layer dt
|
||||
walledCast =
|
||||
V.map wallCast collidedCast
|
||||
cattedCast = V.map
|
||||
(\(Cast c) ->
|
||||
Cast $ collide c oldCat $ collisionCheck dt c oldCat
|
||||
)
|
||||
walledCast
|
||||
in
|
||||
V.map
|
||||
(\(Cast c) -> Cast $
|
||||
move dt c
|
||||
)
|
||||
walledCast
|
||||
updatedCast <- readTVar (testCast level)
|
||||
oldCat <- fromJust <$> readTVar (testPlayer level)
|
||||
releasedEffects <- stateTVar (testPowerups level) $ \pus ->
|
||||
let living = V.foldl
|
||||
(\acc pu ->
|
||||
|
@ -113,10 +118,10 @@ update level dt = liftIO $ do
|
|||
(testPlayer level) $ \(Just pituicat) ->
|
||||
let playedCat = perform dt pituicat
|
||||
castCat =
|
||||
let allPartners = V.zip (V.fromList [0..V.length updatedCast])
|
||||
let allPartners = V.zip (V.fromList [0..V.length oldCast])
|
||||
(V.map
|
||||
(\(Cast c) -> collisionCheck dt playedCat c)
|
||||
updatedCast
|
||||
oldCast
|
||||
)
|
||||
filtered = (V.filter ((/= NoCollision) . snd) allPartners)
|
||||
partner = V.minimumBy
|
||||
|
@ -129,7 +134,7 @@ update level dt = liftIO $ do
|
|||
else
|
||||
uncurry
|
||||
(\(Cast c) cr -> collide playedCat c cr)
|
||||
(updatedCast V.! fst partner, snd partner)
|
||||
(oldCast V.! fst partner, snd partner)
|
||||
walledCat = performWorldCollision castCat layer dt
|
||||
affectedCat = walledCat
|
||||
{ pcEffects = pcEffects walledCat ++
|
||||
|
|
|
@ -76,7 +76,7 @@ instance Actor PowerUp where
|
|||
|
||||
instance Mass PowerUp where
|
||||
|
||||
mass _ = 1
|
||||
mass _ = 0.1
|
||||
|
||||
acceleration = puAcc
|
||||
|
||||
|
|
Loading…
Reference in a new issue