new accessors
This commit is contained in:
parent
05b126ef94
commit
4eaa644cbf
1 changed files with 8 additions and 11 deletions
|
@ -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!"
|
||||
|
|
Loading…
Reference in a new issue