diff options
Diffstat (limited to 'src/HTanks.hs')
-rw-r--r-- | src/HTanks.hs | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/HTanks.hs b/src/HTanks.hs index 660f03c..55d82ec 100644 --- a/src/HTanks.hs +++ b/src/HTanks.hs @@ -21,6 +21,9 @@ import qualified Data.Map as M import qualified Data.Set as S import Data.Time +import Foreign.C.Types + + main :: IO () main = do let theLevel = testLevel @@ -45,7 +48,7 @@ main = do deinitGL gl minFrameTime :: NominalDiffTime -minFrameTime = 0.01 +minFrameTime = 0.02 mainLoop :: Main () mainLoop = do @@ -60,9 +63,10 @@ mainLoop = do rtime <- liftIO getCurrentTime let drender = diffUTCTime rtime t when (drender < minFrameTime) $ - liftIO $ threadDelay $ truncate $ 1e6*(minFrameTime - drender) + liftIO $ usleep gl $ truncate $ 1e6*(minFrameTime - drender) currenttime <- liftIO getCurrentTime + liftIO $ print $ diffUTCTime currenttime rtime let d = round $ 1e2*(diffUTCTime currenttime t) replicateM_ d simulationStep @@ -74,7 +78,6 @@ mainLoop = do runnext <- gets run when runnext mainLoop - handleEvents :: Main () handleEvents = do (newgl, event) <- gets driver >>= liftIO . nextEvent |