module Input where import Keyboard import Random import RandomValues (RandomValues) import Vec2 (Vec2) type Input = { dir : Vec2 , delta : Time , randomValues : RandomValues } getInput : Signal Input getInput = let dtSignal = delta dirSignal = lift recordIntToVec2 Keyboard.arrows randomFloatsSignal = Random.floatList (lift (\_ -> 6) dtSignal) randomValuesSignal = lift floatsToRandomValues randomFloatsSignal in sampleOn dtSignal <| Input <~ dirSignal ~ dtSignal ~ randomValuesSignal delta : Signal Time delta = lift (\ms -> ms) (fps 25) 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 greenPoint = { angle = angle1 , x = x1 , y = y1 } redPoint = { angle = angle2 , x = x2 , y = y2 } in { greenPoint = greenPoint , redPoint = redPoint }