diff --git a/examples/example03.hs b/examples/example03.hs index 8e4f5ca..b6f2b17 100644 --- a/examples/example03.hs +++ b/examples/example03.hs @@ -1,4 +1,5 @@ {-# LANGUAGE RecordWildCards #-} +{-# LANGUAGE BangPatterns #-} import Affection import qualified SDL @@ -173,23 +174,22 @@ update sec evs = do return () ) evs ud2 <- getAffection - nps <- updateParticleSystem (partsys ud2) sec partUpd partDraw + !nps <- updateParticleSystem (partsys ud2) sec partUpd partDraw putAffection $ ud2 { partsys = nps } clean :: UserData -> IO () clean _ = return () partUpd :: Double -> Particle -> Affection UserData Particle -partUpd sec p@Particle{..} = do - let newX = (fst particlePosition) + sec * (fromIntegral $ fst particleVelocity) - newY = (snd particlePosition) + sec * (fromIntegral $ snd particleVelocity) - liftIO $ G.gegl_node_set (particleNodeGraph M.! "rect") $ G.Operation "gegl:rectangle" +partUpd sec p = do + let !newX = (fst $ particlePosition p) + sec * (fromIntegral $ fst $ particleVelocity p) + !newY = (snd $ particlePosition p) + sec * (fromIntegral $ snd $ particleVelocity p) + liftIO $ G.gegl_node_set (particleNodeGraph p M.! "rect") $ G.Operation "gegl:rectangle" [ G.Property "x" $ G.PropertyDouble $ newX - 10 , G.Property "y" $ G.PropertyDouble $ newY - 10 ] - return p - { particlePosition = (newX, newY) - } + let !np = p {particlePosition = (newX, newY)} + return np partDraw :: G.GeglBuffer -> G.GeglNode -> Particle -> Affection UserData () partDraw buf node Particle{..} = do