Gunsmoke as clouds

This commit is contained in:
2021-03-24 03:02:39 +01:00
parent 03587a7906
commit 48e6779503
4 changed files with 53 additions and 72 deletions
+27
View File
@@ -11,6 +11,33 @@ import Picture
import Control.Lens
import qualified Data.IntMap as IM
makeCloudAt :: Float -> Int -> (Cloud -> Picture) -> Point2 -> World -> World
makeCloudAt rad t drawFunc p w
= w & clouds %~ IM.insert i theCloud
where i = newKey $ _clouds w
theCloud = Cloud { _clID = i
, _clPos = p
, _clVel = (0,0)
, _clPict = drawFunc
, _clRad = rad
, _clTimer = t
, _clEffect = const id
}
fadeOutTime :: Color -> Float -> Cloud -> Picture
fadeOutTime col fadet cl = setLayer 2
. setDepth (-0.5)
. color (withAlpha a col)
$ circleSolid (4 * _clRad cl)
where a = min 1 $ fromIntegral (_clTimer cl) / fadet
makeThickSmokeAt :: Point2 -> World -> World
makeThickSmokeAt = makeCloudAt 2 50 (fadeOutTime black 50)
makeThinSmokeAt :: Point2 -> World -> World
makeThinSmokeAt = makeSmokeCloud
makeSmokeCloud :: Point2 -> World -> World
makeSmokeCloud pos w = w & clouds %~ IM.insert i theCloud
where i = newKey $ _clouds w