34 lines
959 B
Haskell
34 lines
959 B
Haskell
module Dodge.Smoke where
|
|
|
|
import Dodge.Data
|
|
import Dodge.Base
|
|
import Dodge.RandomHelp
|
|
import Geometry.Data
|
|
import Picture
|
|
|
|
import Control.Lens
|
|
import Control.Monad.State
|
|
|
|
spawnSmokeAt :: Point2 -> World -> World
|
|
spawnSmokeAt p w =
|
|
w & smoke %~ (:) thesmoke
|
|
& randGen .~ g
|
|
where
|
|
thesmoke = Smoke
|
|
{_smPos = p
|
|
,_smRad = 20
|
|
,_smColor = white
|
|
,_smUpdate = f
|
|
,_smPs = ps
|
|
,_smTime = 500
|
|
}
|
|
f s = case s ^. smPs of
|
|
[] -> Nothing
|
|
_ -> case s ^. smTime of
|
|
0 -> Just $ s & smPs %~ init
|
|
t -> Just $ s & smTime .~ t-1
|
|
(ps,g) = runState (sequence $ replicate 60 $ randInCirc 20) $ _randGen w
|
|
|
|
spawnSmokeAtCursor :: World -> World
|
|
spawnSmokeAtCursor w = spawnSmokeAt (mouseWorldPos w) w
|