From 4d007f6802246c6411a2838e68e957c2b4d56d3d Mon Sep 17 00:00:00 2001 From: Joris Guyonvarch Date: Wed, 4 Mar 2015 23:27:59 +0100 Subject: Adapt the game to elm version 0.14.1 --- src/Input.elm | 44 ++++++++++++-------------------------------- 1 file changed, 12 insertions(+), 32 deletions(-) (limited to 'src/Input.elm') diff --git a/src/Input.elm b/src/Input.elm index 8ba43ec..3723ba3 100644 --- a/src/Input.elm +++ b/src/Input.elm @@ -1,51 +1,31 @@ module Input where import Char (toCode) -import RandomValues (RandomValues) -import Keyboard (KeyCode, keysDown, arrows) +import Keyboard (KeyCode, keysDown, arrows, isDown) import Random +import Time (Time, fps) +import Signal (..) import Vec2 (Vec2) -type Input = +type alias Input = { dir : Vec2 - , inputKeysDown : [KeyCode] + , inputKeysDown : List KeyCode , delta : Time - , randomValues : RandomValues } getInput : Signal Input getInput = - let dtSignal = delta - dirSignal = lift recordIntToVec2 arrows - randomFloatsSignal = Random.floatList (lift (\_ -> 6) dtSignal) - randomValuesSignal = lift floatsToRandomValues randomFloatsSignal - in sampleOn dtSignal <| Input <~ dirSignal - ~ keysDown - ~ dtSignal - ~ randomValuesSignal - -delta : Signal Time -delta = lift (\ms -> ms) (fps 25) + let delta = fps 25 + input = + Input + <~ map recordIntToVec2 arrows + ~ keysDown + ~ delta + in sampleOn delta input recordIntToVec2 : {x : Int, y : Int} -> Vec2 recordIntToVec2 {x, y} = { x = toFloat x , y = toFloat y } - -floatsToRandomValues : [Float] -> RandomValues -floatsToRandomValues [angle1, x1, y1, angle2, x2, y2] = - let point1 = - { angle = angle1 - , x = x1 - , y = y1 - } - point2 = - { angle = angle2 - , x = x2 - , y = y2 - } - in { point1 = point1 - , point2 = point2 - } -- cgit v1.2.3