From 687d5f5b58b3e0bee578af9bf9e47ec476e0ecd8 Mon Sep 17 00:00:00 2001 From: nek0 Date: Sat, 15 Sep 2018 19:22:04 +0200 Subject: [PATCH] smoother game start --- src/MainGame/WorldMap.hs | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/src/MainGame/WorldMap.hs b/src/MainGame/WorldMap.hs index eafc77f..3cf99b1 100644 --- a/src/MainGame/WorldMap.hs +++ b/src/MainGame/WorldMap.hs @@ -200,12 +200,6 @@ loadMapFork ud ad future progress = do ( p + increment , "Registering NPCs into WorldState" ))) - -- posbounds <- efor allEnts $ do - -- with pos - -- with obstacle - -- pos' <- query pos - -- bnds <- query obstacle - -- return (pos', bnds) mapM_ (\crp -> do fact <- liftIO $ randomRIO (0.5, 1.5) -- fut <- liftIO newEmptyMVar @@ -234,16 +228,15 @@ loadMapFork ud ad future progress = do ))) return mmimgmat )) ad - -- nstate <- evalStateT - -- (runState $ yieldSystemT nws (updateNPCs mmimgmat nws rps 0)) ad - putMVar future (nws, MainData - { mapMat = mat - , imgMat = M.fromList (nrows inter) (ncols inter) $ + let retMat = M.fromList (nrows inter) (ncols inter) $ Prelude.map (\a -> if a == Just ImgEmpty || a == Just ImgEmptyNoWalk then Nothing else a) (M.toList inter) + putMVar future (nws, MainData + { mapMat = mat + , imgMat = retMat , reachPoints = rps , mmImgMat = mmimgmat }) @@ -527,15 +520,18 @@ drawTile ud ctx posanims pr pc row col img = updateMap :: Double -> Affection UserData () updateMap dt = do ud <- getAffection - isFut <- liftIO $ isEmptyMVar (stateMVar ud) - if not isFut && stateData ud == None + if stateData ud == None then do liftIO $ logIO A.Debug "Loaded game data" - Just (nws, mendat) <- liftIO $ tryTakeMVar (stateMVar ud) + (nws, mendat) <- liftIO $ takeMVar (stateMVar ud) putAffection ud { worldState = nws , stateData = mendat } + updateMap 0.1 + updateMap 0.1 + updateMap 0.1 + updateMap 19 else do (nws, _) <- yieldSystemT (worldState ud) $ do emap allEnts $ do