Improve static bullets
This commit is contained in:
@@ -1,10 +1,9 @@
|
||||
{- | Creation of particles in the world. -}
|
||||
module Dodge.WorldEvent.SpawnParticle
|
||||
( makeGasCloud
|
||||
, makeFlamelet
|
||||
, aStaticBall
|
||||
, incBall
|
||||
, makeStaticBall
|
||||
, concBall
|
||||
, randParticleAt
|
||||
) where
|
||||
import Dodge.Data
|
||||
import Dodge.Zone
|
||||
@@ -21,6 +20,17 @@ import LensHelp
|
||||
import Data.Foldable
|
||||
import qualified Streaming.Prelude as S
|
||||
|
||||
randParticleAt :: (Point2 -> State StdGen Particle) -> Point2 -> World -> World
|
||||
randParticleAt f p w = w
|
||||
& instantParticles .:~ thepart
|
||||
& randGen .~ g
|
||||
where
|
||||
(thepart,g) = runState (f p) (_randGen w)
|
||||
|
||||
makeStaticBall :: Point2 -> World -> World
|
||||
makeStaticBall p = randParticleAt aStaticBall p . (posEvents .:~ thesparker)
|
||||
where
|
||||
thesparker = PosEvent SparkSpawner 10 p
|
||||
|
||||
concBall :: Point2 -> State g Particle
|
||||
concBall p = return Shockwave
|
||||
@@ -34,10 +44,9 @@ concBall p = return Shockwave
|
||||
, _ptTimer = 10
|
||||
}
|
||||
|
||||
|
||||
aStaticBall :: Point2 -> State g Particle
|
||||
aStaticBall p = return PtStaticBall
|
||||
{ _ptUpdate = moveStaticBall
|
||||
{ _ptUpdate = moveFlamelet
|
||||
, _ptVel = 0
|
||||
, _ptColor = blue
|
||||
, _ptPos = p
|
||||
@@ -47,48 +56,6 @@ aStaticBall p = return PtStaticBall
|
||||
, _ptZ = 20
|
||||
}
|
||||
|
||||
makeFlamelet
|
||||
:: Point2 -- ^ Position
|
||||
-> Float -- ^ z position
|
||||
-> Point2 -- ^ Velocity
|
||||
-> Float -- ^ Size
|
||||
-> Int -- ^ Timer
|
||||
-> World
|
||||
-> World
|
||||
makeFlamelet (V2 x y) z vel size time w = w
|
||||
& randGen .~ g
|
||||
& instantParticles .:~ PtIncBall
|
||||
{ _ptUpdate = moveFlamelet
|
||||
, _ptVel = vel
|
||||
, _ptColor = red
|
||||
, _ptPos = V2 x y
|
||||
, _ptWidth = size
|
||||
, _ptTimer = time
|
||||
, _ptHitEff = expireAndDamage $ simpleDam FLAMING 1
|
||||
, _ptZ = z
|
||||
, _ptRot = rot
|
||||
}
|
||||
where
|
||||
(rot ,g) = randomR (0,3) $ _randGen w
|
||||
|
||||
--damageBothTypeAmount :: DamageType
|
||||
-- -> Int
|
||||
-- -> Particle
|
||||
-- -> [(Point2, Either Creature Wall)]
|
||||
-- -> World
|
||||
-- -> (World, Maybe Particle)
|
||||
--damageBothTypeAmount dt amount = destroyOnImpact
|
||||
-- (\pt p cr -> creatures . ix (_crID cr) . crState . crDamage .:~ thedam pt p)
|
||||
-- (\pt p -> damageWall (thedam pt p))
|
||||
-- where
|
||||
-- thedam pt p = Damage dt amount sp p ep NoDamageEffect
|
||||
-- where
|
||||
-- sp = _ptPos pt
|
||||
-- ep = sp +.+ _ptVel pt
|
||||
|
||||
moveStaticBall :: World -> Particle -> (World, Maybe Particle)
|
||||
moveStaticBall = moveFlamelet
|
||||
|
||||
-- | Note damgeInRadius by itself never destroys the particle
|
||||
damageInRadius :: Float -> Particle -> World -> World
|
||||
damageInRadius size pt = damageInArea isClose closeWls pt
|
||||
@@ -136,20 +103,6 @@ makeGasCloud pos vel w = w
|
||||
(col, g) = runState (takeOne [green,yellow]) $ _randGen w
|
||||
{- Attach poison cloud damage to creatures near cloud. -}
|
||||
|
||||
incBall :: RandomGen g => Point2 -> State g Particle
|
||||
incBall p = do
|
||||
rot <- state $ randomR (0,3)
|
||||
return PtIncBall
|
||||
{ _ptUpdate = moveFlamelet
|
||||
, _ptVel = 0
|
||||
, _ptColor = red
|
||||
, _ptPos = p
|
||||
, _ptWidth = 3
|
||||
, _ptTimer = 20
|
||||
, _ptHitEff = expireAndDamage $ simpleDam FLAMING 1
|
||||
, _ptZ = 20
|
||||
, _ptRot = rot
|
||||
}
|
||||
|
||||
{- Update of a flamelet.
|
||||
Applies movement and attaches damage to nearby creatures. -}
|
||||
|
||||
Reference in New Issue
Block a user