aboutsummaryrefslogtreecommitdiff
path: root/src/Input.elm
diff options
context:
space:
mode:
Diffstat (limited to 'src/Input.elm')
-rw-r--r--src/Input.elm17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/Input.elm b/src/Input.elm
index 1015302..8ba43ec 100644
--- a/src/Input.elm
+++ b/src/Input.elm
@@ -1,13 +1,15 @@
module Input where
-import Keyboard
-import Random
+import Char (toCode)
import RandomValues (RandomValues)
+import Keyboard (KeyCode, keysDown, arrows)
+import Random
import Vec2 (Vec2)
type Input =
{ dir : Vec2
+ , inputKeysDown : [KeyCode]
, delta : Time
, randomValues : RandomValues
}
@@ -15,10 +17,11 @@ type Input =
getInput : Signal Input
getInput =
let dtSignal = delta
- dirSignal = lift recordIntToVec2 Keyboard.arrows
+ dirSignal = lift recordIntToVec2 arrows
randomFloatsSignal = Random.floatList (lift (\_ -> 6) dtSignal)
randomValuesSignal = lift floatsToRandomValues randomFloatsSignal
in sampleOn dtSignal <| Input <~ dirSignal
+ ~ keysDown
~ dtSignal
~ randomValuesSignal
@@ -33,16 +36,16 @@ recordIntToVec2 {x, y} =
floatsToRandomValues : [Float] -> RandomValues
floatsToRandomValues [angle1, x1, y1, angle2, x2, y2] =
- let greenPoint =
+ let point1 =
{ angle = angle1
, x = x1
, y = y1
}
- redPoint =
+ point2 =
{ angle = angle2
, x = x2
, y = y2
}
- in { greenPoint = greenPoint
- , redPoint = redPoint
+ in { point1 = point1
+ , point2 = point2
}