Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
bmh10 committed Mar 12, 2017
1 parent 19074ae commit 29fcd41
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ initialBrickPos = (10, 210)
window = InWindow "Tetris" (width, height) (offset, offset)
background = black

data BlockType = LineBlock | SquareBlock | LBlock | JBlock | TBlock | SBlock | ZBlock
deriving (Enum, Eq, Show, Bounded)
data BlockType = LineBlock | SquareBlock | LBlock | JBlock | TBlock | SBlock | ZBlock deriving (Enum, Eq, Show, Bounded)
data KeyPress = South | East | West | None deriving (Eq, Show)

data Tile = Tile
Expand Down Expand Up @@ -191,12 +190,10 @@ handleKeys (EventKey (SpecialKey KeyDown) Down _ _) g = handleKeyPress $ g { ke
handleKeys (EventKey (SpecialKey KeyUp) Down _ _) g = g { currentBlock = rotateBlock (currentBlock g) }
handleKeys _ g = g { keyPress = None }

rotateBlock b =
recreateBlock $ b { rotation = ((rotation b) + 90) `mod'` 360 }
rotateBlock b = recreateBlock $ b { rotation = ((rotation b) + 90) `mod'` 360 }

update :: Float -> TetrisGame -> TetrisGame
update seconds g
= updateCurrentBlock $ handleKeyPress g
update seconds g = updateCurrentBlock $ handleKeyPress g

handleKeyPress g = moveBlock g (keyPress g)

Expand All @@ -208,10 +205,13 @@ updateCurrentBlock g
| otherwise = moveBlock g South
where (randBlock, gen') = randomBlock (gen g) initialBrickPos

-- TODO: optimize
checkCompletedLines g = if any (f ts) [0,-1..(-500)] then g { score = (score g) + 1 } else g
where ts = getLandedTiles g
f ts n = (length $ filter (\t -> (snd (pos t)) == n) ts) == 20

clearLine ts n = filter (\t -> (snd (pos t)) \= n) ts)

main = do
is <- initGame
play window background fps is render handleKeys update

0 comments on commit 29fcd41

Please sign in to comment.