changing particle draw condition

Now particles are drawn when moving the mouse whilst pressing the left
mouse button
This commit is contained in:
nek0 2016-12-20 05:27:45 +01:00
parent d1c697c204
commit 55ae0bd32a

View file

@ -104,12 +104,15 @@ update sec = do
ev <- liftIO $ SDL.pollEvents ev <- liftIO $ SDL.pollEvents
mapM_ (\e -> mapM_ (\e ->
case SDL.eventPayload e of case SDL.eventPayload e of
SDL.MouseButtonEvent dat -> do SDL.MouseMotionEvent dat ->
let (SDL.P (SDL.V2 x y)) = SDL.mouseButtonEventPos 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) vx <- liftIO $ randomRIO (-20, 20)
vy <- liftIO $ randomRIO (-20, 20) vy <- liftIO $ randomRIO (-20, 20)
life <- liftIO $ randomRIO (1, 5) 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 putAffection $ ud
{ coordinates = Just (fromIntegral x, fromIntegral y) { coordinates = Just (fromIntegral x, fromIntegral y)
, partsys = (partsys ud) , partsys = (partsys ud)
@ -122,6 +125,8 @@ update sec = do
}) : (psParts $ partsys ud) }) : (psParts $ partsys ud)
} }
} }
else
return ()
SDL.WindowClosedEvent _ -> do SDL.WindowClosedEvent _ -> do
traceM "seeya!" traceM "seeya!"
put $ ad put $ ad