added delay option

This commit is contained in:
Thorn Avery 2021-04-21 11:19:57 +12:00
parent 1d0d27cf07
commit 16925c182e
2 changed files with 6 additions and 1 deletions

View File

@ -26,7 +26,7 @@ main = do
chan <- newBChan 1 chan <- newBChan 1
forkIO $ forever $ do forkIO $ forever $ do
writeBChan chan Tick writeBChan chan Tick
threadDelay 70000 threadDelay $ (optTime options) * 10000
g <- initGame g <- initGame
let buildVty = V.mkVty V.defaultConfig let buildVty = V.mkVty V.defaultConfig
initialVty <- buildVty initialVty <- buildVty

View File

@ -13,6 +13,7 @@ data Options = Options
{ optWidth :: Int { optWidth :: Int
, optGenerations :: Int , optGenerations :: Int
, optHeight :: Int , optHeight :: Int
, optTime :: Int
} deriving Show } deriving Show
-- the default options for the program -- the default options for the program
@ -24,6 +25,7 @@ defaultOptions w h = Options
{ optWidth = w { optWidth = w
, optGenerations = 40 , optGenerations = 40
, optHeight = h , optHeight = h
, optTime = 7
} }
-- the avaliable options -- the avaliable options
@ -38,6 +40,9 @@ options =
, Option ['h'] ["height"] , Option ['h'] ["height"]
(ReqArg (\t opts -> opts { optHeight = (read t) }) "HEIGHT") (ReqArg (\t opts -> opts { optHeight = (read t) }) "HEIGHT")
"term height" "term height"
, Option ['t'] ["time"]
(ReqArg (\t opts -> opts { optTime = (read t) }) "TIME")
"delay time"
] ]
-- parse the options into the structure -- parse the options into the structure