20th of November 2015 - Codemotion - Milan
(suffering together at late hours might be team-building but surely we don't need this :P)
As seen on LambdaCat:
type Tile
= Door Size
| Column
| BackGround BackGroundTile
| Shadow ShadowTile
type Maybe a
= Just a
| Nothing
String.toInt : String -> Maybe Int
toMonth : String -> Maybe Int toMonth rawString =
case String.toInt rawString of
Nothing ->
Nothing
Just n ->
if n > 0 && n <= 12 then Just n else Nothing
type alias UserInput = {}
userInput : Signal UserInput
userInput = Signal.constant {}
type alias Input =
{ timeDelta : Float
, userInput : UserInput
}
type alias UserInput = {}
userInput : Signal UserInput
userInput = Signal.constant {}
type alias Input =
{ timeDelta : Float
, userInput : UserInput
}
type alias UserInput = {}
userInput : Signal UserInput
userInput = Signal.constant {}
type alias Input =
{ timeDelta : Float
, userInput : UserInput
}
type alias GameState = {}
defaultGame : GameState
defaultGame = {}
display : (Int,Int) -> GameState -> Element
display (w,h) gameState = show gameState
display : (Int,Int) -> GameState -> Element
display (w,h) gameState = show gameState
stepGame : Input -> GameState -> GameState
stepGame {timeDelta,userInput} gameState =
gameState
delta : Signal Float
delta = Time.fps 30
input : Signal Input
input = Signal.sampleOn delta
(Signal.map2 Input delta userInput)
delta : Signal Float
delta = Time.fps 30
input : Signal Input
input = Signal.sampleOn delta
(Signal.map2 Input delta userInput)
gameState : Signal GameState
gameState = Signal.foldp stepGame
defaultGame input
gameState : Signal GameState
gameState = Signal.foldp stepGame
defaultGame input
main : Signal Element
main = Signal.map2 display
Window.dimensions gameState
main : Signal Element
main = Signal.map2 display
Window.dimensions gameState
merge : Signal a ->
foldp : (a -> state -> state) -> state -> Signal a ->
Signal state
foldp takes (a -> state -> state)
a function
... -> state -> ...
a default state
... -> Signal a -> ...
an input signal
... -> Signal state
returns a signal
(= next state of the program, after applying update)