Refactor clouds

This commit is contained in:
2025-06-24 13:28:17 +01:00
parent b1041d1eb0
commit 444be7b49c
12 changed files with 80 additions and 140 deletions
+4 -65
View File
@@ -1,76 +1,15 @@
module Dodge.WorldEvent.Cloud (
makeFlamerSmokeAt,
smokeCloudAt,
-- makeThinSmokeAt,
-- makeThickSmokeAt,
shellTrailCloud,
spawnSmokeAtCursor,
makeStartCloudAt,
) where
module Dodge.WorldEvent.Cloud (makeCloudAt) where
import Dodge.Base
import Dodge.Data.World
import Geometry.Data
import LensHelp
import Picture
--import System.Random
makeCloudAt ::
-- CloudDraw ->
-- -- | radius
-- Float ->
-- | timer
Int ->
-- | resting altitude
Float ->
Point3 -> -- start position
World ->
World
makeCloudAt t alt p =
makeCloudAt :: CloudType -> Int -> Point3 -> World -> World
makeCloudAt ct t p =
cWorld . lWorld . clouds
.:~ Cloud
{ _clPos = p
, _clVel = V3 0 0 0
-- , _clPict = drawFunc
-- , _clRad = rad
, _clAlt = alt
, _clTimer = t
, _clType = SmokeCloud
, _clType = ct
}
smokeCloudAt ::
Color ->
-- | radius
-- Float ->
-- | timer
Int ->
-- | resting altitude
Float ->
Point3 -> -- start position
World ->
World
smokeCloudAt col = makeCloudAt
--makeThickSmokeAt :: Point3 -> World -> World
--makeThickSmokeAt = makeCloudAt 50 30
--
--makeThinSmokeAt :: Point3 -> World -> World
--makeThinSmokeAt = makeCloudAt 400 50
makeStartCloudAt :: Point3 -> World -> World
--makeStartCloudAt = makeCloudAt (CloudColor 2 800 white) 10 400 5
--makeStartCloudAt = makeCloudAt (CloudColor 2 200 white) 10 400 50
makeStartCloudAt = makeCloudAt 400 50
shellTrailCloud :: Int -> Float -> Point3 -> World -> World
shellTrailCloud age fadet = makeCloudAt age 30
makeFlamerSmokeAt :: Point3 -> World -> World
makeFlamerSmokeAt p w = makeCloudAt 200 40 p w
-- where
-- x = fst $ randomR (0.5, 0.8) (_randGen w)
spawnSmokeAtCursor :: World -> World
spawnSmokeAtCursor w = shellTrailCloud 400 100 (V3 x y 20) w
where
V2 x y = mouseWorldPos (w ^. input) (w ^. wCam)
+1 -9
View File
@@ -15,22 +15,14 @@ makeGasCloud ::
Point2 ->
World ->
World
makeGasCloud pos vel w =
w
& cWorld . lWorld . clouds .:~ theCloud
makeGasCloud pos vel = cWorld . lWorld . clouds .:~ theCloud
where
-- & randGen .~ g
theCloud =
Cloud
{ _clPos = addZ 20 pos
, _clVel = addZ 0 vel
-- , _clPict = CloudColor 50 -- (withAlpha 0.5 col)
, _clAlt = 25
, _clTimer = 400
, _clType = GasCloud
}
-- (col, g) = runState (takeOne [green, yellow]) $ _randGen w
{- Attach poison cloud damage to creatures near cloud. -}