Created
October 10, 2014 12:25
-
-
Save jamesmacaulay/bbfb662b068e8a4e8d60 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Mouse | |
import Array | |
buildAppDataMap delta pos history = | |
{ frameDelta=delta | |
, mousePosition=pos | |
, clickHistory=history } | |
arrayTakeLast n array = | |
let inputLen = Array.length array | |
outputLen = min inputLen n | |
in Array.slice (inputLen - outputLen) inputLen array | |
addToHistory pos hist = | |
arrayTakeLast 4 (Array.push pos hist) | |
clickHistory = Mouse.position | |
|> sampleOn Mouse.clicks | |
|> foldp addToHistory Array.empty | |
appData = buildAppDataMap <~ (fps 25) ~ Mouse.position ~ clickHistory | |
main = lift asText appData |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment