Simplify flamelet balls

This commit is contained in:
2025-08-05 08:47:47 +01:00
parent 22dafda9bd
commit 298238d594
5 changed files with 33 additions and 53 deletions
+1 -1
View File
@@ -122,7 +122,7 @@ useBulletPayload bu = case _buPayload bu of
(_buVel bu)
(ElectricalBall (round $ bu ^. buPos . _1))
BulBall FlashBall -> makeMovingEB (_buVel bu) FlashBall
BulBall (FlameletBall x r) -> makeMovingEB (_buVel bu) (FlameletBall x r)
BulBall (FlameletBall x) -> makeMovingEB (_buVel bu) (FlameletBall x)
BulBall IncendiaryBall -> makeMovingEB (_buVel bu) IncendiaryBall
makeFragBullets :: Point2 -> World -> World
+1 -1
View File
@@ -11,7 +11,7 @@ import Data.Aeson.TH
data EnergyBallType
= IncendiaryBall
| FlameletBall {_fbSize :: Float, _fbRot :: Float}
| FlameletBall {_fbSize :: Float}
| ElectricalBall {_ebID :: Int}
| ExplosiveBall
| FlashBall
+1 -18
View File
@@ -2,7 +2,6 @@
module Dodge.EnergyBall (
updateEnergyBall,
makeFlashBall,
makeFlamelet,
makeMovingEB,
) where
@@ -22,16 +21,13 @@ import Linear.V3
makeFlamelet :: Point3 -> Point3 -> Float -> Int -> World -> World
makeFlamelet p v s t w =
w
& randGen .~ g
& cWorld . lWorld . energyBalls
.:~ EnergyBall
{ _ebVel = v
, _ebPos = p
, _ebTimer = t
, _ebType = FlameletBall s a
, _ebType = FlameletBall s
}
where
(a, g) = randomR (0, 3) $ _randGen w
updateEnergyBall :: World -> EnergyBall -> (World, Maybe EnergyBall)
updateEnergyBall w eb
@@ -62,16 +58,6 @@ ebEffect eb = case _ebType eb of
soundStart (EBSound (-1)) (eb ^. ebPos . _xy) fireFadeS Nothing
_ -> id
energyBallAt :: EnergyBallType -> Point2 -> World -> World
energyBallAt ebt p =
cWorld . lWorld . energyBalls
.:~ EnergyBall
{ _ebVel = 0
, _ebPos = p `v2z` 20
, _ebTimer = 20
, _ebType = ebt
}
makeMovingEB :: Point2 -> EnergyBallType -> Point2 -> World -> World
makeMovingEB v ebt p =
cWorld . lWorld . energyBalls
@@ -82,9 +68,6 @@ makeMovingEB v ebt p =
, _ebType = ebt
}
makeFlashBall :: Point2 -> World -> World
makeFlashBall = energyBallAt FlashBall
ebFlicker :: EnergyBall -> World -> World
ebFlicker pt
| _ebTimer pt `mod` 7 == 0 =
+7 -7
View File
@@ -6,8 +6,8 @@ import Picture
drawEnergyBall :: EnergyBall -> Picture
drawEnergyBall eb = case _ebType eb of
FlameletBall x a -> drawFlamelet x a eb
IncendiaryBall -> drawFlamelet 5 0 eb
FlameletBall x -> drawFlamelet x eb
IncendiaryBall -> drawFlamelet 5 eb
ElectricalBall{} -> drawStaticBall eb
ExplosiveBall -> drawExplosiveBall eb
FlashBall -> mempty
@@ -34,8 +34,8 @@ drawStaticBall pt =
. translate3 (_ebPos pt)
$ circleSolidCol blue (withAlpha 0.5 white) 8
drawFlamelet :: Float -> Float -> EnergyBall -> Picture
drawFlamelet size rot pt =
drawFlamelet :: Float -> EnergyBall -> Picture
drawFlamelet size pt =
fold
[ setLayer BloomLayer pic
, setLayer BloomNoZWrite piu
@@ -58,7 +58,7 @@ drawFlamelet size rot pt =
(V4 2 0 0 1)
(V4 2 0 0 0)
)
. rotate (negate (rot - 0.1 * fromIntegral time))
. rotate (0.1 * fromIntegral time)
. scale s1 s1
. polygon
$ reverse (rectNSWE siz2 (- siz2) (- siz2) siz2)
@@ -75,7 +75,7 @@ drawFlamelet size rot pt =
(V4 2 1 0 0.5)
(V4 0 0 0 0)
)
. rotate (negate (rot + 0.2 * fromIntegral time))
. rotate (negate (0.2 * fromIntegral time))
. scale s2 s2
. polygon
. reverse
@@ -91,7 +91,7 @@ drawFlamelet size rot pt =
(V4 1 1 1 3)
(V4 1 0 0 1)
)
. rotate (negate (0.1 * fromIntegral time + rot))
. rotate (negate (0.1 * fromIntegral time))
. scale (0.5 * sc) (0.5 * sc)
$ polygon $ map toV2 [(- size, - size), (size, - size), (size, size), (- size, size)]
sc = (*) 2 $ log $ 1 + fromIntegral time / 20