adjusted example

This commit is contained in:
nek0 2016-12-18 19:01:53 +01:00
parent 9d50f8a7e0
commit 5a44486477

View file

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