From 55ae0bd32acae9b0f03df8f8a2cba128ae33082c Mon Sep 17 00:00:00 2001 From: nek0 Date: Tue, 20 Dec 2016 05:27:45 +0100 Subject: [PATCH] changing particle draw condition Now particles are drawn when moving the mouse whilst pressing the left mouse button --- examples/example03.hs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/examples/example03.hs b/examples/example03.hs index 46f37b0..2a4f49a 100644 --- a/examples/example03.hs +++ b/examples/example03.hs @@ -104,12 +104,15 @@ update sec = do ev <- liftIO $ SDL.pollEvents mapM_ (\e -> case SDL.eventPayload e of - SDL.MouseButtonEvent dat -> do - let (SDL.P (SDL.V2 x y)) = SDL.mouseButtonEventPos dat + SDL.MouseMotionEvent dat -> + if SDL.ButtonLeft `elem` SDL.mouseMotionEventState dat + then do + let (SDL.P (SDL.V2 x y)) = SDL.mouseMotionEventPos dat vx <- liftIO $ randomRIO (-20, 20) vy <- liftIO $ randomRIO (-20, 20) life <- liftIO $ randomRIO (1, 5) - -- traceM $ "velocity is: " ++ show vx ++ " " ++ show vy + traceM $ "position is: " ++ show x ++ " " ++ show y + traceM $ "velocity is: " ++ show vx ++ " " ++ show vy putAffection $ ud { coordinates = Just (fromIntegral x, fromIntegral y) , partsys = (partsys ud) @@ -122,6 +125,8 @@ update sec = do }) : (psParts $ partsys ud) } } + else + return () SDL.WindowClosedEvent _ -> do traceM "seeya!" put $ ad