mirror of
https://github.com/z0w0/helm.git
synced 2024-09-11 04:15:32 +03:00
22 lines
669 B
Haskell
22 lines
669 B
Haskell
import Control.Applicative
|
|
import FRP.Elerea.Simple
|
|
import FRP.Helm
|
|
import qualified FRP.Helm.Keyboard as Keyboard
|
|
import qualified FRP.Helm.Window as Window
|
|
|
|
data State = State { mx :: Double, my :: Double }
|
|
|
|
step :: (Int, Int) -> State -> State
|
|
step (dx, dy) state = state { mx = (realToFrac dx) + mx state, my = (realToFrac dy) + my state }
|
|
|
|
render :: (Int, Int) -> State -> Element
|
|
render (w, h) (State { .. }) = collage w h [move (mx, my) $ filled (rgb 1 1 1) $ square 100]
|
|
|
|
main :: IO ()
|
|
main = run $ do
|
|
dims <- Window.dimensions
|
|
arrows <- Keyboard.arrows
|
|
stepper <- transfer (State { mx = 0, my = 100 }) step arrows
|
|
|
|
return $ render <$> dims <*> stepper
|