Permalink
Browse files

periodically increase speed

  • Loading branch information...
mlang committed Aug 30, 2018
1 parent 00dea49 commit a8f783a435c2309ad34b79315bb919d442757932
Showing with 5 additions and 1 deletion.
  1. +5 −1 app/Main.hs
View
@@ -4,6 +4,7 @@
module Main where
import Control.Concurrent (forkIO, threadDelay)
import Control.Concurrent.STM.TVar
import Control.Concurrent.STM.TBChan
import Control.Lens
import Control.Monad (forever)
@@ -23,13 +24,16 @@ main = do
vty <- mkVty defaultConfig
chan <- atomically $ newTBChan 10
game <- initGame 0
speed <- newTVarIO 1000000
forkIO $ forever $ do
e <- nextEvent vty
atomically $ writeTBChan chan $ Ev e
forkIO $ forever $ do
threadDelay 1000000
delay <- readTVarIO speed
atomically $ modifyTVar speed ((-) 100)
threadDelay delay
atomically $ writeTBChan chan Tick
consume vty chan game

0 comments on commit a8f783a

Please sign in to comment.