From 5a44486477b81a2c1dbe1aeed8236b1c6a480b63 Mon Sep 17 00:00:00 2001 From: nek0 Date: Sun, 18 Dec 2016 19:01:53 +0100 Subject: [PATCH] adjusted example --- examples/example03.hs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/examples/example03.hs b/examples/example03.hs index 7236074..0142593 100644 --- a/examples/example03.hs +++ b/examples/example03.hs @@ -101,27 +101,26 @@ update sec = do nps <- updateParticleSystem (partsys ud) sec partUpd partDraw putAffection $ ud { partsys = nps } traceM $ (show $ 1 / sec) ++ " FPS" - ev <- liftIO $ SDL.pollEvent - maybe (return ()) (\e -> + ev <- liftIO $ SDL.pollEvents + mapM_ (\e -> case SDL.eventPayload e of - SDL.MouseButtonEvent dat -> if sec < 0.03 - then do + SDL.MouseButtonEvent dat -> do let (SDL.P (SDL.V2 x y)) = SDL.mouseButtonEventPos dat vx <- liftIO $ randomRIO (-20, 20) vy <- liftIO $ randomRIO (-20, 20) + life <- liftIO $ randomRIO (1, 5) traceM $ "velocity is: " ++ show vx ++ " " ++ show vy putAffection $ ud { coordinates = Just (fromIntegral x, fromIntegral y) , partsys = (partsys ud) { psParts = (Particle - { particleLife = 5 + { particleLife = life , particlePosition = (fromIntegral x, fromIntegral y) , particleRotation = 0 , particleVelocity = (vx, vy) }) : (psParts $ partsys ud) } } - else return () SDL.WindowClosedEvent _ -> do traceM "seeya!" put $ ad