-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.elm
More file actions
37 lines (32 loc) · 922 Bytes
/
Copy pathMain.elm
File metadata and controls
37 lines (32 loc) · 922 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
module Main exposing (..)
import Time exposing (Time, every, second, now)
import AnimationFrame
import Keyboard exposing (KeyCode)
import Html.App exposing (program)
import Actions exposing (..)
import Model exposing (..)
import Update exposing (..)
import View exposing (..)
subs : Model -> Sub Action
subs model =
Sub.batch
[ AnimationFrame.diffs Tick
, Keyboard.downs (\code -> key code model)
]
key : KeyCode -> Model -> Action
key keycode model =
case keycode of
32 -> if model.state /= GameOver then
Jump
else if model.state == GameOver && model.scoreBoard.opacity == 1 then
Restart
else
NoOp
_ -> NoOp
main =
program
{ init = ( Model.initial, Cmd.none )
, update = (\action model -> ( update action model, Cmd.none ))
, subscriptions = subs
, view = scene
}