Skip to content

Commit f6845aa

Browse files
committed
Streamline mainLoop
1 parent 7e8bbee commit f6845aa

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

app/Main.hs

+5-5
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ main = do
1111
setupTerm
1212
inputSource <- startInputLoop
1313
seed <- fmap fromInteger getCPUTime
14-
mainLoop (freshGame seed) inputSource
14+
mainLoop inputSource (freshGame seed)
1515
where
1616
setupTerm = hSetBuffering stdin NoBuffering >>
1717
hSetEcho stdin False >> hideCursor
1818

19-
mainLoop :: Game -> InputSource -> IO ()
20-
mainLoop g@Game{gameOver=False} is =
21-
drawGame g >> getInputEvent is >>= \i -> mainLoop (updateGame i g) is
22-
mainLoop g@Game{gameScore=s} _ =
19+
mainLoop :: InputSource -> Game -> IO ()
20+
mainLoop is g@Game{gameOver=False} =
21+
drawGame g >> getInputEvent is >>= mainLoop is . flip updateGame g
22+
mainLoop _ g@Game{gameScore=s} =
2323
drawGame g >> (putStrLn $ "You cleared: " ++ (show s) ++ " lines.") >>
2424
showCursor
2525

src/Tetris/Model/Board.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ board cs = Board { boardCells = concat cs
6565
boardRows :: Board -> [[Cell]]
6666
boardRows b = mapChunks id (boardWidth b) (boardCells b)
6767

68-
emptyCell,fullCell :: Cell
68+
emptyCell, fullCell :: Cell
6969
emptyCell = Cell False
7070
fullCell = Cell True
7171

0 commit comments

Comments
 (0)