Finish level picker, start game interface
This commit is contained in:
parent
315f486520
commit
c12bef50b3
4 changed files with 205 additions and 36 deletions
39
app/Main.hs
39
app/Main.hs
|
@ -1,41 +1,14 @@
|
|||
module Main where
|
||||
|
||||
import Control.Concurrent (threadDelay, forkIO)
|
||||
import Control.Monad (void, forever)
|
||||
import Tetris (Game)
|
||||
|
||||
import Tetris
|
||||
|
||||
import Brick
|
||||
import Brick.BChan
|
||||
import qualified Graphics.Vty as V
|
||||
|
||||
-- | Ticks mark passing of time
|
||||
data Tick = Tick
|
||||
|
||||
-- | Named resources
|
||||
type Name = ()
|
||||
|
||||
app :: App Game Tick Name
|
||||
app = undefined
|
||||
import UI.PickLevel (pickLevel)
|
||||
import UI.Game (playGame)
|
||||
|
||||
-- | TODO possibly allow a small number of CLI args,
|
||||
-- like tetris --high-score
|
||||
main :: IO ()
|
||||
main = pickLevel >>= playGame
|
||||
|
||||
pickLevel :: IO Int
|
||||
pickLevel = undefined
|
||||
|
||||
playGame :: Int -> IO ()
|
||||
playGame lvl = do
|
||||
let delay = levelToDelay lvl
|
||||
chan <- newBChan 10
|
||||
forkIO $ forever $ do
|
||||
writeBChan chan Tick
|
||||
threadDelay delay
|
||||
initialGame <- initGame lvl
|
||||
customMain (V.mkVty V.defaultConfig) (Just chan) app initialGame >>= handleEndGame
|
||||
|
||||
levelToDelay :: Int -> Int
|
||||
levelToDelay = undefined
|
||||
main = pickLevel >>= playGame >>= handleEndGame
|
||||
|
||||
-- | TODO possibly save high score (with 3 initials? kick it real old school?) to ~/.tetris
|
||||
handleEndGame :: Game -> IO ()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue