From 4eaa644cbf5d0eb68fa17cb4597cfdbc4e681b6e Mon Sep 17 00:00:00 2001 From: nek0 Date: Mon, 12 Dec 2016 02:11:31 +0100 Subject: [PATCH] new accessors --- examples/example02.hs | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/examples/example02.hs b/examples/example02.hs index 5d66681..71cf8b4 100644 --- a/examples/example02.hs +++ b/examples/example02.hs @@ -68,16 +68,15 @@ load _ = do drawInit :: Affection UserData () drawInit = do - AffectionData{..} <- get - let UserData{..} = userState + UserData{..} <- getAffection present (nodeGraph M.! "over") foreground (GeglRectangle 0 0 800 600) True draw :: Affection UserData () draw = do traceM "drawing" - AffectionData{..} <- get - let UserData{..} = userState - SDL.V2 (CInt rw) (CInt rh) <- SDL.surfaceDimensions drawSurface + ad <- get + UserData{..} <- getAffection + SDL.V2 (CInt rw) (CInt rh) <- SDL.surfaceDimensions $ drawSurface ad let (w, h) = (fromIntegral rw, fromIntegral rh) liftIO $ clearArea foreground (GeglRectangle 0 0 w h) maybe (return ()) (\(x, y) -> @@ -92,18 +91,16 @@ draw = do update :: Double -> AffectionState (AffectionData UserData) IO () update sec = do traceM "updating" - ad@AffectionData{..} <- get - let ud@UserData{..} = userState + ad <- get + ud <- getAffection traceM $ (show $ 1 / sec) ++ " FPS" ev <- liftIO $ SDL.pollEvent maybe (return ()) (\e -> case SDL.eventPayload e of SDL.MouseMotionEvent dat -> do let (SDL.P (SDL.V2 x y)) = SDL.mouseMotionEventPos dat - put $ ad - { userState = ud - { coordinates = Just (fromIntegral x, fromIntegral y) - } + putAffection $ ud + { coordinates = Just (fromIntegral x, fromIntegral y) } SDL.WindowClosedEvent _ -> do traceM "seeya!"