Skip to content

Instantly share code, notes, and snippets.

@scan
Created August 18, 2012 17:44
Show Gist options
  • Save scan/3388692 to your computer and use it in GitHub Desktop.
Save scan/3388692 to your computer and use it in GitHub Desktop.
playerPos :: (Float, Float) -> SF (Float, Float) (Float, Float)
playerPos p0 = proc speed -> do
rec
p' <- (^+^ p0) ^<< integral -< speed
pos <- arr clampPos -< (p', pos)
returnA -< pos
where clampPos ((x,y), (ox, oy)) = (clamp x ox 40 720, clamp y oy 40 520)
clamp a v mi ma | a > mi && a < ma = a
| otherwise = v
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment