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
1 changed files with 8 additions and 3 deletions

View File

@ -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