adjusted example
This commit is contained in:
parent
9d50f8a7e0
commit
5a44486477
1 changed files with 5 additions and 6 deletions
|
@ -101,27 +101,26 @@ update sec = do
|
||||||
nps <- updateParticleSystem (partsys ud) sec partUpd partDraw
|
nps <- updateParticleSystem (partsys ud) sec partUpd partDraw
|
||||||
putAffection $ ud { partsys = nps }
|
putAffection $ ud { partsys = nps }
|
||||||
traceM $ (show $ 1 / sec) ++ " FPS"
|
traceM $ (show $ 1 / sec) ++ " FPS"
|
||||||
ev <- liftIO $ SDL.pollEvent
|
ev <- liftIO $ SDL.pollEvents
|
||||||
maybe (return ()) (\e ->
|
mapM_ (\e ->
|
||||||
case SDL.eventPayload e of
|
case SDL.eventPayload e of
|
||||||
SDL.MouseButtonEvent dat -> if sec < 0.03
|
SDL.MouseButtonEvent dat -> do
|
||||||
then do
|
|
||||||
let (SDL.P (SDL.V2 x y)) = SDL.mouseButtonEventPos dat
|
let (SDL.P (SDL.V2 x y)) = SDL.mouseButtonEventPos 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)
|
||||||
traceM $ "velocity is: " ++ show vx ++ " " ++ show vy
|
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)
|
||||||
{ psParts = (Particle
|
{ psParts = (Particle
|
||||||
{ particleLife = 5
|
{ particleLife = life
|
||||||
, particlePosition = (fromIntegral x, fromIntegral y)
|
, particlePosition = (fromIntegral x, fromIntegral y)
|
||||||
, particleRotation = 0
|
, particleRotation = 0
|
||||||
, particleVelocity = (vx, vy)
|
, particleVelocity = (vx, vy)
|
||||||
}) : (psParts $ partsys ud)
|
}) : (psParts $ partsys ud)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else return ()
|
|
||||||
SDL.WindowClosedEvent _ -> do
|
SDL.WindowClosedEvent _ -> do
|
||||||
traceM "seeya!"
|
traceM "seeya!"
|
||||||
put $ ad
|
put $ ad
|
||||||
|
|
Loading…
Reference in a new issue