summaryrefslogtreecommitdiffstats
path: root/src/HTanks.hs
diff options
context:
space:
mode:
authorMatthias Schiffer <matthias@gamezock.de>2010-04-07 15:07:27 +0200
committerMatthias Schiffer <matthias@gamezock.de>2010-04-07 15:07:27 +0200
commitd6b28723a26151d8ac6cb195d4e2135b05fdac5a (patch)
tree3b70252d6384a1a4434364095c3b600118872307 /src/HTanks.hs
parentc0d2d54ea1687a80ff76fa032ad4dc89670d2988 (diff)
downloadhtanks-d6b28723a26151d8ac6cb195d4e2135b05fdac5a.tar
htanks-d6b28723a26151d8ac6cb195d4e2135b05fdac5a.zip
Use system sleep functions as threadDelay sleep to long without -threaded
Diffstat (limited to 'src/HTanks.hs')
-rw-r--r--src/HTanks.hs9
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