Skip to content

Instantly share code, notes, and snippets.

@bstro
Last active May 25, 2016 17:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bstro/4a1c5b56d0c2a69830362301e780ac8e to your computer and use it in GitHub Desktop.
Save bstro/4a1c5b56d0c2a69830362301e780ac8e to your computer and use it in GitHub Desktop.
(=>) = (,)
update : Msg -> Model -> (Model, Cmd Msg)
update msg model =
case msg of
NoOp
-> model
=> Cmd.none
Init res
-> ({ model | resolution = Just res })
=> Cmd.none
Tick time
->
let piece = model.activeBlock
in case piece of
Just v ->
if model.timeout < 1000
then { model | timeout = model.timeout+time } => Cmd.none
else { model | timeout = 0.0 } => Task.perform never (\t -> Rotate t) (succeed v)
Nothing ->
model => Cmd.none
Rotate piece
->
let rotated = rotatePiece piece
in { model | board = [Just rotated] }
=> Cmd.none
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment