aboutsummaryrefslogtreecommitdiff
path: root/src/Main.elm
blob: 42bcbc46c18eeaa26ca62eae0b89ab60eb1a569f (plain)
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
38
39
40
41
module Main
  ( main
  ) where

import Signal
import Html (Html)
import Time (..)
import Mouse
import Json.Encode (Value)
import Keyboard
import Char

import Model.Model (..)
import Model.Position (..)
import Update.Update (..)
import View.View (view)

main : Signal Html
main = Signal.map view model

model : Signal Model
model = Signal.foldp update (initialModel initialTime) input

input : Signal Action
input =
  Signal.mergeMany
    [ Signal.subscribe updates
    , Signal.map DeltaTime (fps 30)
    , Signal.map (\_ -> ReadOnly) clickAway
    , Signal.map KeyPressed Keyboard.lastPressed
    ]

port clickPosition : Signal Value
port clickPosition =
  Signal.sampleOn
    Mouse.clicks
    (Signal.map positionEncoder Mouse.position)

port clickAway : Signal ()

port initialTime : Time