better camera handling

This commit is contained in:
nek0 2017-03-29 00:44:36 +02:00
parent 705f032035
commit 66b8f54a07

View file

@ -135,7 +135,8 @@ drawInit = do
ad <- get
ud <- getAffection
process (nodeGraph ud M.! "sink")
present (GeglRectangle 0 0 3289 600) (foreground ud) True
present (GeglRectangle (round $ cameraX ud) 0 800 600) (foreground ud) True
render Nothing Nothing
draw :: Affection UserData ()
draw = do
@ -181,14 +182,10 @@ update dt = do
"rect"
(actors ud)
let {
offset | xpos - cameraX ud > 750 && cameraX ud + leg < 2489 =
case code of
SDL.KeycodeRight -> leg
_ -> 0
| xpos - cameraX ud < 50 && cameraX ud - leg > 0 =
case code of
SDL.KeycodeLeft -> (-leg)
_ -> 0
offset | xpos - cameraX ud > 750 && cameraX ud + leg < 2489 && code == SDL.KeycodeRight =
leg
| xpos - cameraX ud < 50 && cameraX ud - leg > 0 && code == SDL.KeycodeLeft =
(-leg)
| otherwise = 0
}
putAffection ud