Reify cloud drawing, move gust data

This commit is contained in:
2022-07-23 19:09:54 +01:00
parent f4808676e2
commit 9d92cbfb9e
8 changed files with 56 additions and 25 deletions
+7 -13
View File
@@ -18,7 +18,7 @@ import LensHelp
import System.Random
makeCloudAt
:: (Cloud -> Picture) -- ^ draw function
:: CloudDraw
-> Float -- ^ radius
-> Int -- ^ timer
-> Float -- ^ resting altitude
@@ -44,29 +44,23 @@ smokeCloudAt
-> Point3 -- start position
-> World
-> World
smokeCloudAt col = makeCloudAt (drawCloudWith (4/3) 800 col)
smokeCloudAt col = makeCloudAt (CloudColor (4/3) 800 col)
drawCloudWith :: Float -> Float -> Color -> Cloud -> Picture
drawCloudWith radMult fadet col cl = setLayer MidLayer
. setDepth 25
$ circleSolidCol (withAlpha 0 col) (withAlpha a col) (radMult * _clRad cl)
where
a = min 1 $ fromIntegral (_clTimer cl) / fadet
makeThickSmokeAt :: Point3 -> World -> World
makeThickSmokeAt = makeCloudAt (drawCloudWith 4 50 black) 3 50 30
makeThickSmokeAt = makeCloudAt (CloudColor 4 50 black) 3 50 30
makeThinSmokeAt :: Point3 -> World -> World
makeThinSmokeAt = makeCloudAt (drawCloudWith 4 400 (withAlpha 0.05 black)) 5 400 50
makeThinSmokeAt = makeCloudAt (CloudColor 4 400 (withAlpha 0.05 black)) 5 400 50
makeStartCloudAt :: Point3 -> World -> World
makeStartCloudAt = makeCloudAt (drawCloudWith 2 800 white) 10 400 5
makeStartCloudAt = makeCloudAt (CloudColor 2 800 white) 10 400 5
shellTrailCloud :: Point3 -> World -> World
shellTrailCloud = makeCloudAt (drawCloudWith (4/3) 800 (greyN 0.5)) 15 400 40
shellTrailCloud = makeCloudAt (CloudColor (4/3) 800 (greyN 0.5)) 15 400 40
makeFlamerSmokeAt :: Point3 -> World -> World
makeFlamerSmokeAt p w = makeCloudAt (drawCloudWith 4 300 (greyN x)) 6 200 40 p w
makeFlamerSmokeAt p w = makeCloudAt (CloudColor 4 300 (greyN x)) 6 200 40 p w
where
x = fst $ randomR (0.5,0.8) (_randGen w)
+1 -2
View File
@@ -91,8 +91,7 @@ makeGasCloud pos vel w = w
theCloud = Cloud
{ _clPos = addZ 20 pos
, _clVel = addZ 0 vel
, _clPict = \_ -> setLayer MidLayer . setDepth 30 $ color (withAlpha 0.05 col)
$ circleSolid 20
, _clPict = DrawGasCloud col
, _clRad = 10
, _clAlt = 25
, _clTimer = 400