From 8ec499a0a9c0e3430f598aa433df57b312cbdb8c Mon Sep 17 00:00:00 2001 From: Sam Tay Date: Sat, 17 Jun 2017 11:05:40 -0400 Subject: [PATCH] Stop elements in row 1 --- src/Tetris.hs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Tetris.hs b/src/Tetris.hs index eb9fc73..15c00fe 100644 --- a/src/Tetris.hs +++ b/src/Tetris.hs @@ -217,7 +217,9 @@ blockStopped g = isStopped (g ^. board) (g ^. block) -- | Check if a block on a board is stopped from further gravitation isStopped :: Board -> Block -> Bool -isStopped b = any (`M.member` b) . map (translate Down) . coords +isStopped brd = any cStopped . coords + where cStopped = (||) <$> inRow1 <*> (`M.member` brd) . (translate Down) + inRow1 (_,y) = y == 1 -- | Freeze current block freezeBlock :: Game -> Game