Move bullets into own data type
This commit is contained in:
@@ -20,10 +20,10 @@ moduleModification imt = case imt of
|
|||||||
DRUMMAG -> itConsumption . laMax .~ 45
|
DRUMMAG -> itConsumption . laMax .~ 45
|
||||||
BELTMAG -> itConsumption . laMax .~ 150
|
BELTMAG -> itConsumption . laMax .~ 150
|
||||||
MAGNETMAG -> itUse . useDelay . rateMax .~ 4
|
MAGNETMAG -> itUse . useDelay . rateMax .~ 4
|
||||||
INCENDBUL -> f $ expireAndDamage $ spawnAtBulDams incBall
|
INCENDBUL -> f $ expireAndDamage' $ spawnAtBulDams incBall
|
||||||
BOUNCEBUL -> f $ expireAndDamage bounceBulDams
|
BOUNCEBUL -> f $ expireAndDamage' bounceBulDams
|
||||||
STATICBUL -> f $ expireAndDamage $ spawnAtBulDams aStaticBall
|
STATICBUL -> f $ expireAndDamage' $ spawnAtBulDams aStaticBall
|
||||||
CONCUSBUL -> f $ expireAndDamage $ spawnAtBulDams concBall
|
CONCUSBUL -> f $ expireAndDamage' $ spawnAtBulDams concBall
|
||||||
TARGCR -> itTargeting .~ targetRBCreature
|
TARGCR -> itTargeting .~ targetRBCreature
|
||||||
TARGLAS -> itTargeting .~ targetLaser
|
TARGLAS -> itTargeting .~ targetLaser
|
||||||
TARGPOS -> itTargeting .~ targetRBPress
|
TARGPOS -> itTargeting .~ targetRBPress
|
||||||
|
|||||||
@@ -42,20 +42,24 @@ applyDamageEffect dm de cr w = case de of
|
|||||||
& creatures . ix (_crID cr) . crPos .+.+~ (1/_crMass cr) *.* pback
|
& creatures . ix (_crID cr) . crPos .+.+~ (1/_crMass cr) *.* pback
|
||||||
TorqueDamage rot -> w
|
TorqueDamage rot -> w
|
||||||
& creatures . ix (_crID cr) . crDir +~ rot
|
& creatures . ix (_crID cr) . crDir +~ rot
|
||||||
BounceBullet bt | crIsArmouredFrom p cr -> w & instantParticles .:~ bouncer
|
BounceBullet bt | crIsArmouredFrom p cr -> w & instantBullets .:~ bouncer
|
||||||
where
|
where
|
||||||
bouncer = (aBulAt Nothing id (Just (_ptColor bt)) pOut reflectVel (_btDrag bt)
|
bouncer = (aBulAt Nothing id (Just (_buColor bt)) pOut reflectVel (_buDrag bt)
|
||||||
(_ptHitEff bt) (_ptWidth bt)
|
(_buHitEff bt) (_buWidth bt)
|
||||||
) {_ptTimer = _ptTimer bt - 1}
|
) {_buTimer = _buTimer bt - 1}
|
||||||
pOut = p +.+ 2 *.* newDir
|
pOut = p +.+ 2 *.* newDir
|
||||||
reflectVel = magV bulVel *.* newDir
|
reflectVel = magV bulVel *.* newDir
|
||||||
newDir = squashNormalizeV (p -.- _crPos cr)
|
newDir = squashNormalizeV (p -.- _crPos cr)
|
||||||
bulVel = _ptVel bt
|
bulVel = _buVel bt
|
||||||
BounceBullet _ -> w
|
BounceBullet _ -> w
|
||||||
DamageSpawn f -> w & instantParticles .:~ thepart
|
DamageSpawn f -> w & instantParticles .:~ thepart
|
||||||
& randGen .~ g
|
& randGen .~ g
|
||||||
where
|
where
|
||||||
(thepart,g) = runState (f (Left cr) dm) $ _randGen w
|
(thepart,g) = runState (f (Left cr) dm) $ _randGen w
|
||||||
|
DamageSpawn' f -> w & instantBullets .:~ thepart
|
||||||
|
& randGen .~ g
|
||||||
|
where
|
||||||
|
(thepart,g) = runState (f (Left cr) dm) $ _randGen w
|
||||||
NoDamageEffect -> w
|
NoDamageEffect -> w
|
||||||
where
|
where
|
||||||
fromDir = _dmFrom dm
|
fromDir = _dmFrom dm
|
||||||
|
|||||||
+34
-13
@@ -141,6 +141,8 @@ data World = World
|
|||||||
, _gusts :: IM.IntMap Gust
|
, _gusts :: IM.IntMap Gust
|
||||||
, _gsZoning :: Zoning IM.IntMap Gust
|
, _gsZoning :: Zoning IM.IntMap Gust
|
||||||
, _props :: IM.IntMap Prop
|
, _props :: IM.IntMap Prop
|
||||||
|
, _instantBullets :: [Bullet]
|
||||||
|
, _bullets :: [Bullet]
|
||||||
, _instantParticles :: [Particle]
|
, _instantParticles :: [Particle]
|
||||||
, _particles :: [Particle]
|
, _particles :: [Particle]
|
||||||
, _radarBlips :: [RadarBlip]
|
, _radarBlips :: [RadarBlip]
|
||||||
@@ -229,7 +231,7 @@ data Magnet = Magnet
|
|||||||
{ _mgID :: Int
|
{ _mgID :: Int
|
||||||
, _mgUpdate :: Magnet -> Maybe Magnet
|
, _mgUpdate :: Magnet -> Maybe Magnet
|
||||||
, _mgPos :: Point2
|
, _mgPos :: Point2
|
||||||
, _mgField :: Magnet -> Particle -> Particle
|
, _mgField :: Magnet -> Bullet -> Bullet
|
||||||
}
|
}
|
||||||
|
|
||||||
data OptionScreenFlag = NormalOptions | GameOverOptions
|
data OptionScreenFlag = NormalOptions | GameOverOptions
|
||||||
@@ -522,6 +524,17 @@ data BeamType
|
|||||||
{_beamCombine :: (Point2 , (Point2,Point2,Beam) , (Point2,Point2,Beam)) -> World -> World}
|
{_beamCombine :: (Point2 , (Point2,Point2,Beam) , (Point2,Point2,Beam)) -> World -> World}
|
||||||
| BeamSimple
|
| BeamSimple
|
||||||
|
|
||||||
|
data Bullet = Bullet
|
||||||
|
{ _buUpdate :: World -> Bullet -> (World, Maybe Bullet)
|
||||||
|
, _buVel :: Point2
|
||||||
|
, _buDrag :: Float
|
||||||
|
, _buColor :: Color
|
||||||
|
, _buTrail :: [Point2]
|
||||||
|
, _buWidth :: Float
|
||||||
|
, _buTimer :: Int
|
||||||
|
, _buHitEff :: HitEffect'
|
||||||
|
}
|
||||||
|
|
||||||
{- Objects without ids.
|
{- Objects without ids.
|
||||||
Update themselves, perhaps with side effects. -}
|
Update themselves, perhaps with side effects. -}
|
||||||
data Particle
|
data Particle
|
||||||
@@ -540,6 +553,16 @@ data Particle
|
|||||||
, _ptPhaseV :: Float
|
, _ptPhaseV :: Float
|
||||||
, _ptPoints :: [Point2]
|
, _ptPoints :: [Point2]
|
||||||
}
|
}
|
||||||
|
| PtSpark
|
||||||
|
{ _ptUpdate :: World -> Particle -> (World, Maybe Particle)
|
||||||
|
, _ptVel :: Point2
|
||||||
|
, _ptDrag :: Float
|
||||||
|
, _ptColor :: Color
|
||||||
|
, _ptTrail :: [Point2]
|
||||||
|
, _ptWidth :: Float
|
||||||
|
, _ptTimer :: Int
|
||||||
|
, _ptHitEff :: HitEffect
|
||||||
|
}
|
||||||
| PtTeslaArc
|
| PtTeslaArc
|
||||||
{ _ptUpdate :: World -> Particle -> (World, Maybe Particle)
|
{ _ptUpdate :: World -> Particle -> (World, Maybe Particle)
|
||||||
, _ptPoints :: [Point2]
|
, _ptPoints :: [Point2]
|
||||||
@@ -551,16 +574,6 @@ data Particle
|
|||||||
, _ptPoints :: [Point2]
|
, _ptPoints :: [Point2]
|
||||||
, _ptColor :: Color
|
, _ptColor :: Color
|
||||||
}
|
}
|
||||||
| BulletPt
|
|
||||||
{ _ptUpdate :: World -> Particle -> (World, Maybe Particle)
|
|
||||||
, _ptVel :: Point2
|
|
||||||
, _btDrag :: Float
|
|
||||||
, _ptColor :: Color
|
|
||||||
, _ptTrail :: [Point2]
|
|
||||||
, _ptWidth :: Float
|
|
||||||
, _ptTimer :: Int
|
|
||||||
, _ptHitEff :: HitEffect
|
|
||||||
}
|
|
||||||
| PtFlame
|
| PtFlame
|
||||||
{ _ptUpdate :: World -> Particle -> (World, Maybe Particle)
|
{ _ptUpdate :: World -> Particle -> (World, Maybe Particle)
|
||||||
, _ptVel :: Point2
|
, _ptVel :: Point2
|
||||||
@@ -625,6 +638,11 @@ type HitEffect = Particle
|
|||||||
-> World
|
-> World
|
||||||
-> (World,Maybe Particle)
|
-> (World,Maybe Particle)
|
||||||
|
|
||||||
|
type HitEffect' = Bullet
|
||||||
|
-> Stream (Of (Point2, Either Creature Wall)) Identity ()
|
||||||
|
-> World
|
||||||
|
-> (World,Maybe Bullet)
|
||||||
|
|
||||||
data BulletTrajectory
|
data BulletTrajectory
|
||||||
= BasicBulletTrajectory
|
= BasicBulletTrajectory
|
||||||
| BezierTrajectory
|
| BezierTrajectory
|
||||||
@@ -641,7 +659,7 @@ data AmmoType
|
|||||||
}
|
}
|
||||||
| BulletAmmo
|
| BulletAmmo
|
||||||
{ _amString :: String
|
{ _amString :: String
|
||||||
, _amBulEff :: HitEffect
|
, _amBulEff :: HitEffect'
|
||||||
, _amBulWth :: Float
|
, _amBulWth :: Float
|
||||||
, _amBulVel :: Point2
|
, _amBulVel :: Point2
|
||||||
, _amBulTraj :: BulletTrajectory
|
, _amBulTraj :: BulletTrajectory
|
||||||
@@ -1230,9 +1248,11 @@ data DamageEffect
|
|||||||
}
|
}
|
||||||
| TorqueDamage { _deTorque :: Float }
|
| TorqueDamage { _deTorque :: Float }
|
||||||
| PushBackDamage {_dePushBack :: Point2 }
|
| PushBackDamage {_dePushBack :: Point2 }
|
||||||
| BounceBullet {_bulToBounce :: Particle}
|
| BounceBullet {_bulToBounce :: Bullet}
|
||||||
| DamageSpawn {_spawnFunc
|
| DamageSpawn {_spawnFunc
|
||||||
:: Either Creature Wall -> Damage -> State StdGen Particle}
|
:: Either Creature Wall -> Damage -> State StdGen Particle}
|
||||||
|
| DamageSpawn' {_spawnFunc'
|
||||||
|
:: Either Creature Wall -> Damage -> State StdGen Bullet}
|
||||||
| NoDamageEffect
|
| NoDamageEffect
|
||||||
-- deriving (Eq,Ord,Show)
|
-- deriving (Eq,Ord,Show)
|
||||||
|
|
||||||
@@ -1388,6 +1408,7 @@ makeLenses ''TweakParam
|
|||||||
makeLenses ''Prop
|
makeLenses ''Prop
|
||||||
makeLenses ''Modification
|
makeLenses ''Modification
|
||||||
makeLenses ''Particle
|
makeLenses ''Particle
|
||||||
|
makeLenses ''Bullet
|
||||||
makeLenses ''PressPlate
|
makeLenses ''PressPlate
|
||||||
makeLenses ''Button
|
makeLenses ''Button
|
||||||
makeLenses ''ActionPlan
|
makeLenses ''ActionPlan
|
||||||
|
|||||||
@@ -39,6 +39,8 @@ defaultWorld = World
|
|||||||
, _gsZoning = Zoning IM.empty clZoneSize (zonePos _guPos)
|
, _gsZoning = Zoning IM.empty clZoneSize (zonePos _guPos)
|
||||||
, _itemPositions = IM.empty
|
, _itemPositions = IM.empty
|
||||||
, _props = IM.empty
|
, _props = IM.empty
|
||||||
|
, _instantBullets = []
|
||||||
|
, _bullets = []
|
||||||
, _instantParticles = []
|
, _instantParticles = []
|
||||||
, _particles = []
|
, _particles = []
|
||||||
, _radarBlips = []
|
, _radarBlips = []
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import Data.Maybe
|
|||||||
--import Control.Lens
|
--import Control.Lens
|
||||||
|
|
||||||
useAmmoParams :: Maybe Float -> Item -> Creature -> World -> World
|
useAmmoParams :: Maybe Float -> Item -> Creature -> World -> World
|
||||||
useAmmoParams vfact it cr w = w & instantParticles .:~ aBulAt
|
useAmmoParams vfact it cr w = w & instantBullets .:~ aBulAt
|
||||||
vfact
|
vfact
|
||||||
thetraj -- extra update
|
thetraj -- extra update
|
||||||
Nothing -- color (default)
|
Nothing -- color (default)
|
||||||
@@ -34,15 +34,15 @@ useAmmoParams vfact it cr w = w & instantParticles .:~ aBulAt
|
|||||||
BasicBulletTrajectory -> id
|
BasicBulletTrajectory -> id
|
||||||
MagnetTrajectory -> fromMaybe id $ do
|
MagnetTrajectory -> fromMaybe id $ do
|
||||||
tpos <- it ^? itTargeting . tgPos . _Just
|
tpos <- it ^? itTargeting . tgPos . _Just
|
||||||
return $ \pt -> pt & ptVel .+.+~ 5 *.* normalizeV (tpos -.- head (_ptTrail pt))
|
return $ \pt -> pt & buVel .+.+~ 5 *.* normalizeV (tpos -.- head (_buTrail pt))
|
||||||
FlechetteTrajectory -> fromMaybe id $ do
|
FlechetteTrajectory -> fromMaybe id $ do
|
||||||
tpos <- it ^? itTargeting . tgPos . _Just
|
tpos <- it ^? itTargeting . tgPos . _Just
|
||||||
return $ \pt -> pt & ptVel %~ vecTurnTo 0.2 (head $ _ptTrail pt) tpos
|
return $ \pt -> pt & buVel %~ vecTurnTo 0.2 (head $ _buTrail pt) tpos
|
||||||
BezierTrajectory -> fromMaybe id $ do
|
BezierTrajectory -> fromMaybe id $ do
|
||||||
tpos <- it ^? itTargeting . tgPos . _Just
|
tpos <- it ^? itTargeting . tgPos . _Just
|
||||||
let bf t = bQuadToF (sp,mouseWorldPos w,tpos) $ (100 - t) * 0.05
|
let bf t = bQuadToF (sp,mouseWorldPos w,tpos) $ (100 - t) * 0.05
|
||||||
return $ \pt -> pt
|
return $ \pt -> pt
|
||||||
& ptVel .~ bf (fromIntegral $ _ptTimer pt - 1) -.- bf (fromIntegral $ _ptTimer pt)
|
& buVel .~ bf (fromIntegral $ _buTimer pt - 1) -.- bf (fromIntegral $ _buTimer pt)
|
||||||
|
|
||||||
---- this shouldn't really be used
|
---- this shouldn't really be used
|
||||||
loadedAmmo :: Item -> Int
|
loadedAmmo :: Item -> Int
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import Geometry.Data
|
|||||||
basicBullet :: AmmoType
|
basicBullet :: AmmoType
|
||||||
basicBullet = BulletAmmo
|
basicBullet = BulletAmmo
|
||||||
{ _amString = "BASIC"
|
{ _amString = "BASIC"
|
||||||
, _amBulEff = expireAndDamage basicBulDams
|
, _amBulEff = expireAndDamage' basicBulDams
|
||||||
, _amBulWth = 2
|
, _amBulWth = 2
|
||||||
, _amBulVel = V2 50 0
|
, _amBulVel = V2 50 0
|
||||||
, _amBulTraj = BasicBulletTrajectory
|
, _amBulTraj = BasicBulletTrajectory
|
||||||
@@ -18,7 +18,7 @@ basicBullet = BulletAmmo
|
|||||||
hvBullet :: AmmoType
|
hvBullet :: AmmoType
|
||||||
hvBullet = BulletAmmo
|
hvBullet = BulletAmmo
|
||||||
{ _amString = "HVBULLET"
|
{ _amString = "HVBULLET"
|
||||||
, _amBulEff = expireAndDamage hvBulDams
|
, _amBulEff = expireAndDamage' hvBulDams
|
||||||
, _amBulWth = 6
|
, _amBulWth = 6
|
||||||
, _amBulVel = V2 80 0
|
, _amBulVel = V2 80 0
|
||||||
, _amBulTraj = BasicBulletTrajectory
|
, _amBulTraj = BasicBulletTrajectory
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ bangRod = defaultBulletWeapon
|
|||||||
& itUse . useAim . aimZoom .~ defaultItZoom {_itZoomFac = 1.5}
|
& itUse . useAim . aimZoom .~ defaultItZoom {_itZoomFac = 1.5}
|
||||||
& itUse . useAim . aimHandlePos .~ 5
|
& itUse . useAim . aimHandlePos .~ 5
|
||||||
& itUse . useAim . aimMuzPos .~ 30
|
& itUse . useAim . aimMuzPos .~ 30
|
||||||
& itConsumption . laAmmoType . amBulEff .~ expireAndDamage heavyBulDams
|
& itConsumption . laAmmoType . amBulEff .~ expireAndDamage' heavyBulDams
|
||||||
elephantGun :: Item
|
elephantGun :: Item
|
||||||
elephantGun = bangRod
|
elephantGun = bangRod
|
||||||
& itType . iyBase .~ HELD ELEPHANTGUN
|
& itType . iyBase .~ HELD ELEPHANTGUN
|
||||||
|
|||||||
+7
-7
@@ -4,23 +4,23 @@ import Geometry
|
|||||||
|
|
||||||
import Control.Lens
|
import Control.Lens
|
||||||
|
|
||||||
dampField :: Magnet -> Particle -> Particle
|
dampField :: Magnet -> Bullet -> Bullet
|
||||||
dampField mg pt = case pt of
|
dampField mg pt = case pt of
|
||||||
BulletPt{} | dist (head $ _ptTrail pt) (_mgPos mg) < 100 -> pt & ptVel *~ 0.5
|
Bullet{} | dist (head $ _buTrail pt) (_mgPos mg) < 100 -> pt & buVel *~ 0.5
|
||||||
_ -> pt
|
_ -> pt
|
||||||
|
|
||||||
curveLeftField :: Magnet -> Particle -> Particle
|
curveLeftField :: Magnet -> Bullet -> Bullet
|
||||||
curveLeftField mg pt = case pt of
|
curveLeftField mg pt = case pt of
|
||||||
BulletPt{} | dist (head $ _ptTrail pt) (_mgPos mg) < 500 -> pt & ptVel %~ rotateV 0.2
|
Bullet{} | dist (head $ _buTrail pt) (_mgPos mg) < 500 -> pt & buVel %~ rotateV 0.2
|
||||||
_ -> pt
|
_ -> pt
|
||||||
|
|
||||||
curveAroundField :: Float -> Float -> Magnet -> Particle -> Particle
|
curveAroundField :: Float -> Float -> Magnet -> Bullet -> Bullet
|
||||||
curveAroundField minrad maxrad mg pt = case pt of
|
curveAroundField minrad maxrad mg pt = case pt of
|
||||||
BulletPt{} | thedist < maxrad -> pt & ptVel %~ rotateToCircle
|
Bullet{} | thedist < maxrad -> pt & buVel %~ rotateToCircle
|
||||||
where
|
where
|
||||||
thedist = dist btpos mgpos
|
thedist = dist btpos mgpos
|
||||||
mgpos = _mgPos mg
|
mgpos = _mgPos mg
|
||||||
btpos = head $ _ptTrail pt
|
btpos = head $ _buTrail pt
|
||||||
rotateToCircle vel
|
rotateToCircle vel
|
||||||
| (isLHS mgpos btpos (btpos +.+ vel) && isRHS mgpos btpos (mgpos +.+ vNormal vel) )
|
| (isLHS mgpos btpos (btpos +.+ vel) && isRHS mgpos btpos (mgpos +.+ vNormal vel) )
|
||||||
|| (isRHS mgpos btpos (btpos +.+ vel) && isLHS mgpos btpos (mgpos +.+ vNormal vel) )
|
|| (isRHS mgpos btpos (btpos +.+ vel) && isLHS mgpos btpos (mgpos +.+ vNormal vel) )
|
||||||
|
|||||||
@@ -4,9 +4,9 @@ module Dodge.Particle.Bullet.Draw
|
|||||||
import Dodge.Data
|
import Dodge.Data
|
||||||
import Picture
|
import Picture
|
||||||
|
|
||||||
drawBul :: Particle -> Picture
|
drawBul :: Bullet -> Picture
|
||||||
drawBul pt = setLayer BloomNoZWrite
|
drawBul pt = setLayer BloomNoZWrite
|
||||||
. setDepth 20
|
. setDepth 20
|
||||||
. color (_ptColor pt)
|
. color (_buColor pt)
|
||||||
-- $ thickLine (_ptWidth pt) (take 3 $ _ptTrail pt)
|
-- $ thickLine (_ptWidth pt) (take 3 $ _ptTrail pt)
|
||||||
$ thickLine (_ptWidth pt) (take 2 $ _ptTrail pt)
|
$ thickLine (_buWidth pt) (take 2 $ _buTrail pt)
|
||||||
|
|||||||
@@ -12,27 +12,26 @@ import Data.Bifunctor
|
|||||||
|
|
||||||
aBulAt
|
aBulAt
|
||||||
:: Maybe Float -- ^ Start velocity step factor
|
:: Maybe Float -- ^ Start velocity step factor
|
||||||
-> (Particle -> Particle)
|
-> (Bullet -> Bullet)
|
||||||
-> Maybe Color
|
-> Maybe Color
|
||||||
-> Point2 -- ^ Start position
|
-> Point2 -- ^ Start position
|
||||||
-> Point2 -- ^ Velocity
|
-> Point2 -- ^ Velocity
|
||||||
-> Float -- ^ Drag
|
-> Float -- ^ Drag
|
||||||
-> HitEffect
|
-> HitEffect'
|
||||||
-> Float -- ^ Bullet width
|
-> Float -- ^ Bullet width
|
||||||
-> Particle
|
-> Bullet
|
||||||
aBulAt vfact updatemod mcol pos vel drag hiteff width = BulletPt
|
aBulAt vfact updatemod mcol pos vel drag hiteff width = Bullet
|
||||||
{ _ptUpdate = theupdate
|
{ _buUpdate = theupdate
|
||||||
, _ptVel = fromMaybe 1 vfact *.* vel
|
, _buVel = fromMaybe 1 vfact *.* vel
|
||||||
, _btDrag = drag
|
, _buDrag = drag
|
||||||
, _ptColor = fromMaybe (V4 200 200 200 2) mcol
|
, _buColor = fromMaybe (V4 200 200 200 2) mcol
|
||||||
-- , _ptColor = V4 2 2 2 2
|
, _buTrail = [pos]
|
||||||
, _ptTrail = [pos]
|
, _buWidth = width
|
||||||
, _ptWidth = width
|
, _buTimer = 100
|
||||||
, _ptTimer = 100
|
, _buHitEff = hiteff
|
||||||
, _ptHitEff = hiteff
|
|
||||||
}
|
}
|
||||||
where
|
where
|
||||||
theupdate = case vfact of
|
theupdate = case vfact of
|
||||||
Just _ -> \w -> resetVel . mvBullet w . updatemod
|
Just _ -> \w -> resetVel . mvBullet w . updatemod
|
||||||
Nothing -> \w -> mvBullet w . updatemod
|
Nothing -> \w -> mvBullet w . updatemod
|
||||||
resetVel = second $ fmap $ (ptUpdate .~ (\w -> mvBullet w . updatemod)) . (ptVel .~ vel)
|
resetVel = second $ fmap $ (buUpdate .~ (\w -> mvBullet w . updatemod)) . (buVel .~ vel)
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
{- Bullet update. -}
|
{- Bullet update. -}
|
||||||
module Dodge.Particle.Bullet.Update
|
module Dodge.Particle.Bullet.Update
|
||||||
( mvBullet
|
( mvBullet
|
||||||
|
, mvSpark
|
||||||
) where
|
) where
|
||||||
import Dodge.Data
|
import Dodge.Data
|
||||||
--import Dodge.Base
|
--import Dodge.Base
|
||||||
@@ -12,15 +13,29 @@ import LensHelp
|
|||||||
|
|
||||||
import Data.Bifunctor
|
import Data.Bifunctor
|
||||||
{- Update for a generic bullet. -}
|
{- Update for a generic bullet. -}
|
||||||
mvBullet :: World -> Particle -> (World, Maybe Particle)
|
mvBullet :: World -> Bullet -> (World, Maybe Bullet)
|
||||||
mvBullet w bt'
|
mvBullet w bt'
|
||||||
| t <= 0 || magV (_ptVel bt) < 1 = (w,Nothing)
|
| t <= 0 || magV (_buVel bt) < 1 = (w,Nothing)
|
||||||
| otherwise = second (fmap dodrag) $
|
| otherwise = second (fmap dodrag) $
|
||||||
hiteff bt (thingsHit p (p +.+ vel) w) w
|
hiteff bt (thingsHit p (p +.+ vel) w) w
|
||||||
where
|
where
|
||||||
bt = foldr (\mg b -> _mgField mg mg b) bt' $ _magnets w
|
bt = foldr (\mg b -> _mgField mg mg b) bt' $ _magnets w
|
||||||
|
dodrag = buVel .*.*~ drag
|
||||||
|
drag = _buDrag bt
|
||||||
|
(p:_) = _buTrail bt
|
||||||
|
vel = _buVel bt
|
||||||
|
hiteff = _buHitEff bt
|
||||||
|
t = _buTimer bt
|
||||||
|
|
||||||
|
mvSpark :: World -> Particle -> (World, Maybe Particle)
|
||||||
|
mvSpark w bt'
|
||||||
|
| t <= 0 || magV (_ptVel bt) < 1 = (w,Nothing)
|
||||||
|
| otherwise = second (fmap dodrag) $
|
||||||
|
hiteff bt (thingsHit p (p +.+ vel) w) w
|
||||||
|
where
|
||||||
|
bt = bt'
|
||||||
dodrag = ptVel .*.*~ drag
|
dodrag = ptVel .*.*~ drag
|
||||||
drag = _btDrag bt
|
drag = _ptDrag bt
|
||||||
(p:_) = _ptTrail bt
|
(p:_) = _ptTrail bt
|
||||||
vel = _ptVel bt
|
vel = _ptVel bt
|
||||||
hiteff = _ptHitEff bt
|
hiteff = _ptHitEff bt
|
||||||
|
|||||||
@@ -8,43 +8,49 @@ import Control.Monad.State
|
|||||||
|
|
||||||
-- TODO unify particle position in a sensible manner
|
-- TODO unify particle position in a sensible manner
|
||||||
spawnAtBulDams :: (Point2 -> State StdGen Particle)
|
spawnAtBulDams :: (Point2 -> State StdGen Particle)
|
||||||
-> Particle -> Point2 -> [Damage]
|
-> Bullet -> Point2 -> [Damage]
|
||||||
spawnAtBulDams thespawn bt p =
|
spawnAtBulDams thespawn bt p =
|
||||||
[ Damage PIERCING 50 sp p ep (DamageSpawn $ \_ dm -> thespawn (_dmAt dm))
|
[ Damage PIERCING 50 sp p ep (DamageSpawn $ \_ dm -> thespawn (_dmAt dm))
|
||||||
, Damage PUSHDAM 1 sp p ep . PushBackDamage $ 2 *.* bulVel
|
, Damage PUSHDAM 1 sp p ep . PushBackDamage $ 2 *.* bulVel
|
||||||
]
|
]
|
||||||
where
|
where
|
||||||
sp = head $ _ptTrail bt
|
sp = head $ _buTrail bt
|
||||||
bulVel = _ptVel bt
|
bulVel = _buVel bt
|
||||||
ep = sp +.+ bulVel
|
ep = sp +.+ bulVel
|
||||||
|
|
||||||
simpleDam :: DamageType -> Int -> Particle -> Point2 -> [Damage]
|
simpleDam :: DamageType -> Int -> Particle -> Point2 -> [Damage]
|
||||||
simpleDam dt amount bt p = [ Damage dt amount sp p ep NoDamageEffect ]
|
simpleDam dt amount bt p = [ Damage dt amount sp p ep NoDamageEffect ]
|
||||||
where
|
where
|
||||||
sp = case bt ^? ptTrail of
|
sp = _ptPos bt
|
||||||
Nothing -> _ptPos bt
|
|
||||||
Just xs -> head xs
|
|
||||||
bulVel = _ptVel bt
|
bulVel = _ptVel bt
|
||||||
ep = sp +.+ bulVel
|
ep = sp +.+ bulVel
|
||||||
|
simpleDam' :: DamageType -> Int -> Bullet -> Point2 -> [Damage]
|
||||||
|
simpleDam' dt amount bt p = [ Damage dt amount sp p ep NoDamageEffect ]
|
||||||
|
where
|
||||||
|
sp = case bt ^? buTrail of
|
||||||
|
Nothing -> 0
|
||||||
|
Just xs -> head xs
|
||||||
|
bulVel = _buVel bt
|
||||||
|
ep = sp +.+ bulVel
|
||||||
|
|
||||||
heavyBulDams :: Particle -> Point2 -> [Damage]
|
heavyBulDams :: Bullet -> Point2 -> [Damage]
|
||||||
heavyBulDams bt p =
|
heavyBulDams bt p =
|
||||||
[ Damage PIERCING 300 sp p ep NoDamageEffect
|
[ Damage PIERCING 300 sp p ep NoDamageEffect
|
||||||
, Damage PUSHDAM 1 sp p ep . PushBackDamage $ 2 *.* bulVel
|
, Damage PUSHDAM 1 sp p ep . PushBackDamage $ 2 *.* bulVel
|
||||||
]
|
]
|
||||||
where
|
where
|
||||||
sp = head $ _ptTrail bt
|
sp = head $ _buTrail bt
|
||||||
bulVel = _ptVel bt
|
bulVel = _buVel bt
|
||||||
ep = sp +.+ bulVel
|
ep = sp +.+ bulVel
|
||||||
|
|
||||||
basicBulDams :: Particle -> Point2 -> [Damage]
|
basicBulDams :: Bullet -> Point2 -> [Damage]
|
||||||
basicBulDams bt p =
|
basicBulDams bt p =
|
||||||
[ Damage PIERCING 100 sp p ep NoDamageEffect
|
[ Damage PIERCING 100 sp p ep NoDamageEffect
|
||||||
, Damage PUSHDAM 1 sp p ep . PushBackDamage $ 2 *.* bulVel
|
, Damage PUSHDAM 1 sp p ep . PushBackDamage $ 2 *.* bulVel
|
||||||
]
|
]
|
||||||
where
|
where
|
||||||
sp = head $ _ptTrail bt
|
sp = head $ _buTrail bt
|
||||||
bulVel = _ptVel bt
|
bulVel = _buVel bt
|
||||||
ep = sp +.+ bulVel
|
ep = sp +.+ bulVel
|
||||||
|
|
||||||
basicSparkDams :: Particle -> Point2 -> [Damage]
|
basicSparkDams :: Particle -> Point2 -> [Damage]
|
||||||
@@ -54,7 +60,7 @@ basicSparkDams bt p = [ Damage SPARKING 1 sp p ep NoDamageEffect ]
|
|||||||
bulVel = _ptVel bt
|
bulVel = _ptVel bt
|
||||||
ep = sp +.+ bulVel
|
ep = sp +.+ bulVel
|
||||||
|
|
||||||
hvBulDams :: Particle -> Point2 -> [Damage]
|
hvBulDams :: Bullet -> Point2 -> [Damage]
|
||||||
hvBulDams bt p =
|
hvBulDams bt p =
|
||||||
[ Damage PIERCING 25 sp p ep NoDamageEffect
|
[ Damage PIERCING 25 sp p ep NoDamageEffect
|
||||||
, Damage PIERCING 25 sp p ep NoDamageEffect
|
, Damage PIERCING 25 sp p ep NoDamageEffect
|
||||||
@@ -66,16 +72,16 @@ hvBulDams bt p =
|
|||||||
, Damage PUSHDAM 1 sp p ep . PushBackDamage $ 3 *.* (ep -.- sp)
|
, Damage PUSHDAM 1 sp p ep . PushBackDamage $ 3 *.* (ep -.- sp)
|
||||||
]
|
]
|
||||||
where
|
where
|
||||||
sp = head $ _ptTrail bt
|
sp = head $ _buTrail bt
|
||||||
bulVel = _ptVel bt
|
bulVel = _buVel bt
|
||||||
ep = sp +.+ bulVel
|
ep = sp +.+ bulVel
|
||||||
|
|
||||||
bounceBulDams :: Particle -> Point2 -> [Damage]
|
bounceBulDams :: Bullet -> Point2 -> [Damage]
|
||||||
bounceBulDams bt p =
|
bounceBulDams bt p =
|
||||||
[ Damage PIERCING 80 sp p ep (BounceBullet bt)
|
[ Damage PIERCING 80 sp p ep (BounceBullet bt)
|
||||||
, Damage PUSHDAM 1 sp p ep . PushBackDamage $ 2 *.* bulVel
|
, Damage PUSHDAM 1 sp p ep . PushBackDamage $ 2 *.* bulVel
|
||||||
]
|
]
|
||||||
where
|
where
|
||||||
sp = head $ _ptTrail bt
|
sp = head $ _buTrail bt
|
||||||
bulVel = _ptVel bt
|
bulVel = _buVel bt
|
||||||
ep = sp +.+ bulVel
|
ep = sp +.+ bulVel
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ drawParticle pt = case pt of
|
|||||||
PtStaticBall {} -> drawStaticBall pt
|
PtStaticBall {} -> drawStaticBall pt
|
||||||
PtIncBall {} -> drawFlameletZ pt
|
PtIncBall {} -> drawFlameletZ pt
|
||||||
PtInvShockwave {} -> drawInverseShockwave pt
|
PtInvShockwave {} -> drawInverseShockwave pt
|
||||||
BulletPt {} -> drawBul pt
|
PtSpark {} -> drawSpark pt
|
||||||
PtTeslaArc {} -> drawTeslaArc pt
|
PtTeslaArc {} -> drawTeslaArc pt
|
||||||
PtTargetLaser {} -> drawTargetLaser pt
|
PtTargetLaser {} -> drawTargetLaser pt
|
||||||
LaserParticle {} -> drawLaser pt
|
LaserParticle {} -> drawLaser pt
|
||||||
@@ -124,8 +124,15 @@ drawInverseShockwave pt
|
|||||||
rad = r - 0.1 * r * fromIntegral (10 - t)
|
rad = r - 0.1 * r * fromIntegral (10 - t)
|
||||||
thickness = fromIntegral (10 - t) **2 * rad / 40
|
thickness = fromIntegral (10 - t) **2 * rad / 40
|
||||||
|
|
||||||
drawBul :: Particle -> Picture
|
drawBul :: Bullet -> Picture
|
||||||
drawBul pt = setLayer BloomNoZWrite
|
drawBul pt = setLayer BloomNoZWrite
|
||||||
|
. setDepth 20
|
||||||
|
. color (_buColor pt)
|
||||||
|
-- $ thickLine (_ptWidth pt) (take 3 $ _ptTrail pt)
|
||||||
|
$ thickLine (_buWidth pt) (take 2 $ _buTrail pt)
|
||||||
|
|
||||||
|
drawSpark :: Particle -> Picture
|
||||||
|
drawSpark pt = setLayer BloomNoZWrite
|
||||||
. setDepth 20
|
. setDepth 20
|
||||||
. color (_ptColor pt)
|
. color (_ptColor pt)
|
||||||
-- $ thickLine (_ptWidth pt) (take 3 $ _ptTrail pt)
|
-- $ thickLine (_ptWidth pt) (take 3 $ _ptTrail pt)
|
||||||
|
|||||||
@@ -8,19 +8,20 @@ import Dodge.Particle.HitEffect.ExpireAndDamage
|
|||||||
import Geometry
|
import Geometry
|
||||||
|
|
||||||
import Data.Bifunctor
|
import Data.Bifunctor
|
||||||
type HitCreatureEffect = Particle -> Point2 -> Creature -> World -> World
|
|
||||||
type HitWallEffect = Particle -> Point2 -> Wall -> World -> World
|
type HitCreatureEffect' = Bullet -> Point2 -> Creature -> World -> World
|
||||||
|
type HitWallEffect' = Bullet -> Point2 -> Wall -> World -> World
|
||||||
|
|
||||||
penWalls
|
penWalls
|
||||||
:: HitCreatureEffect
|
:: HitCreatureEffect'
|
||||||
-> HitWallEffect
|
-> HitWallEffect'
|
||||||
-> Particle
|
-> Bullet
|
||||||
-> [(Point2, Either Creature Wall)]
|
-> [(Point2, Either Creature Wall)]
|
||||||
-> World
|
-> World
|
||||||
-> (World, Maybe Particle)
|
-> (World, Maybe Bullet)
|
||||||
penWalls crEff wlEff pt hitThings w = case hitThings of
|
penWalls crEff wlEff pt hitThings w = case hitThings of
|
||||||
[] -> ( w, mvPt pt)
|
[] -> ( w, mvPt pt)
|
||||||
((p,Left cr):_) -> (crEff pt p cr w, destroyAt p pt)
|
((p,Left cr):_) -> (crEff pt p cr w, destroyAt' p pt)
|
||||||
((p,Right wl):hs) | _wlFireThrough wl
|
((p,Right wl):hs) | _wlFireThrough wl
|
||||||
-> first (wlEff pt p wl) $ penWalls crEff wlEff pt hs w
|
-> first (wlEff pt p wl) $ penWalls crEff wlEff pt hs w
|
||||||
((p,Right wl):_) -> (wlEff pt p wl w, destroyAt p pt)
|
((p,Right wl):_) -> (wlEff pt p wl w, destroyAt' p pt)
|
||||||
|
|||||||
@@ -14,9 +14,18 @@ expireAndDamage :: (Particle -> Point2 -> [Damage])
|
|||||||
-> World
|
-> World
|
||||||
-> (World, Maybe Particle)
|
-> (World, Maybe Particle)
|
||||||
expireAndDamage fdm bt things w = case runIdentity $ S.head_ things of
|
expireAndDamage fdm bt things w = case runIdentity $ S.head_ things of
|
||||||
Nothing -> (w, mvPt bt)
|
Nothing -> (w, mvPt' bt)
|
||||||
Just x -> (doDamages fdm x bt w, destroyAt (fst x) bt)
|
Just x -> (doDamages fdm x bt w, destroyAt (fst x) bt)
|
||||||
|
|
||||||
|
expireAndDamage' :: (Bullet -> Point2 -> [Damage])
|
||||||
|
-> Bullet
|
||||||
|
-> Stream (Of (Point2, Either Creature Wall)) Identity ()
|
||||||
|
-> World
|
||||||
|
-> (World, Maybe Bullet)
|
||||||
|
expireAndDamage' fdm bt things w = case runIdentity $ S.head_ things of
|
||||||
|
Nothing -> (w, mvPt bt)
|
||||||
|
Just x -> (doDamages' fdm x bt w, destroyAt' (fst x) bt)
|
||||||
|
|
||||||
doDamages :: (Particle -> Point2 -> [Damage])
|
doDamages :: (Particle -> Point2 -> [Damage])
|
||||||
-> (Point2, Either Creature Wall)
|
-> (Point2, Either Creature Wall)
|
||||||
-> Particle
|
-> Particle
|
||||||
@@ -27,3 +36,14 @@ doDamages fdm (p,thhit) bt = case thhit of
|
|||||||
Right wl -> wallDamages %~ IM.insertWith (++) (_wlID wl) dams
|
Right wl -> wallDamages %~ IM.insertWith (++) (_wlID wl) dams
|
||||||
where
|
where
|
||||||
dams = fdm bt p
|
dams = fdm bt p
|
||||||
|
|
||||||
|
doDamages' :: (Bullet -> Point2 -> [Damage])
|
||||||
|
-> (Point2, Either Creature Wall)
|
||||||
|
-> Bullet
|
||||||
|
-> World
|
||||||
|
-> World
|
||||||
|
doDamages' fdm (p,thhit) bt = case thhit of
|
||||||
|
Left cr -> creatures . ix (_crID cr) . crState . csDamage .++~ dams
|
||||||
|
Right wl -> wallDamages %~ IM.insertWith (++) (_wlID wl) dams
|
||||||
|
where
|
||||||
|
dams = fdm bt p
|
||||||
|
|||||||
@@ -10,16 +10,16 @@ import Streaming
|
|||||||
import qualified Streaming.Prelude as S
|
import qualified Streaming.Prelude as S
|
||||||
|
|
||||||
penetrate
|
penetrate
|
||||||
:: ((Point2,Either Creature Wall) -> Particle -> Maybe Particle)
|
:: ((Point2,Either Creature Wall) -> Bullet -> Maybe Bullet)
|
||||||
-- | penetration test, can update particle if it penetrates
|
-- | penetration test, can update particle if it penetrates
|
||||||
-> (Particle -> Point2 -> [Damage]) -- | damages when penetrating
|
-> (Bullet -> Point2 -> [Damage]) -- | damages when penetrating
|
||||||
-> (Particle -> Point2 -> [Damage]) -- | damages when not penetrating
|
-> (Bullet -> Point2 -> [Damage]) -- | damages when not penetrating
|
||||||
-> Particle
|
-> Bullet
|
||||||
-> Stream (Of (Point2, Either Creature Wall)) Identity ()
|
-> Stream (Of (Point2, Either Creature Wall)) Identity ()
|
||||||
-> World
|
-> World
|
||||||
-> (World, Maybe Particle)
|
-> (World, Maybe Bullet)
|
||||||
penetrate t pendam stopdam pt hitThings w = case runIdentity $ S.uncons hitThings of
|
penetrate t pendam stopdam pt hitThings w = case runIdentity $ S.uncons hitThings of
|
||||||
Nothing -> (w, mvPt pt)
|
Nothing -> (w, mvPt pt)
|
||||||
Just (x,xs) -> case t x pt of
|
Just (x,xs) -> case t x pt of
|
||||||
Nothing -> expireAndDamage stopdam pt hitThings w
|
Nothing -> expireAndDamage' stopdam pt hitThings w
|
||||||
Just pt' -> first (doDamages pendam x pt) $ penetrate t pendam stopdam pt' xs w
|
Just pt' -> first (doDamages' pendam x pt) $ penetrate t pendam stopdam pt' xs w
|
||||||
|
|||||||
@@ -19,10 +19,10 @@ import System.Random
|
|||||||
--import Control.Lens
|
--import Control.Lens
|
||||||
-- TODO remove/simplify this function
|
-- TODO remove/simplify this function
|
||||||
createBarrelSpark :: Point2 -> Float -> Int -> Int -> World -> World
|
createBarrelSpark :: Point2 -> Float -> Int -> Int -> World -> World
|
||||||
createBarrelSpark pos dir time colid = instantParticles .:~ BulletPt
|
createBarrelSpark pos dir time colid = instantParticles .:~ PtSpark
|
||||||
{ _ptUpdate = mvBullet
|
{ _ptUpdate = mvSpark
|
||||||
, _ptVel = rotateV dir (V2 5 0)
|
, _ptVel = rotateV dir (V2 5 0)
|
||||||
, _btDrag = 0.9
|
, _ptDrag = 0.9
|
||||||
, _ptColor = numColor colid
|
, _ptColor = numColor colid
|
||||||
, _ptTrail = [pos]
|
, _ptTrail = [pos]
|
||||||
, _ptWidth = 1
|
, _ptWidth = 1
|
||||||
@@ -48,9 +48,9 @@ randColDirTimeSpark randcol randdir randtime pos w = w
|
|||||||
d <- randdir
|
d <- randdir
|
||||||
t <- randtime
|
t <- randtime
|
||||||
return (c,d,t)
|
return (c,d,t)
|
||||||
spark = BulletPt
|
spark = PtSpark
|
||||||
{ _ptUpdate = mvBullet
|
{ _ptUpdate = mvSpark
|
||||||
, _btDrag = 0.9
|
, _ptDrag = 0.9
|
||||||
, _ptVel = rotateV dir (V2 5 0)
|
, _ptVel = rotateV dir (V2 5 0)
|
||||||
, _ptColor = col
|
, _ptColor = col
|
||||||
, _ptTrail = [pos]
|
, _ptTrail = [pos]
|
||||||
@@ -66,9 +66,9 @@ colSparkRandDir randDir time col pos baseDir w = w
|
|||||||
where
|
where
|
||||||
(a,g) = randomR (-randDir,randDir) $ _randGen w
|
(a,g) = randomR (-randDir,randDir) $ _randGen w
|
||||||
dir = a + baseDir
|
dir = a + baseDir
|
||||||
spark = BulletPt
|
spark = PtSpark
|
||||||
{ _ptUpdate = mvBullet
|
{ _ptUpdate = mvSpark
|
||||||
, _btDrag = 0.9
|
, _ptDrag = 0.9
|
||||||
, _ptVel = rotateV dir (V2 5 0)
|
, _ptVel = rotateV dir (V2 5 0)
|
||||||
, _ptColor = col
|
, _ptColor = col
|
||||||
, _ptTrail = [pos]
|
, _ptTrail = [pos]
|
||||||
|
|||||||
@@ -3,8 +3,15 @@ import Dodge.Data
|
|||||||
import LensHelp
|
import LensHelp
|
||||||
import Geometry
|
import Geometry
|
||||||
|
|
||||||
mvPt :: Particle -> Maybe Particle
|
mvPt :: Bullet -> Maybe Bullet
|
||||||
mvPt pt = Just $ pt
|
mvPt pt = Just $ pt
|
||||||
|
& buTrail %~ f
|
||||||
|
& buTimer -~ 1
|
||||||
|
where
|
||||||
|
f trl = head trl +.+ _buVel pt : trl
|
||||||
|
|
||||||
|
mvPt' :: Particle -> Maybe Particle
|
||||||
|
mvPt' pt = Just $ pt
|
||||||
& ptTrail %~ f
|
& ptTrail %~ f
|
||||||
& ptTimer -~ 1
|
& ptTimer -~ 1
|
||||||
where
|
where
|
||||||
@@ -12,12 +19,25 @@ mvPt pt = Just $ pt
|
|||||||
|
|
||||||
destroyAt :: Point2 -> Particle -> Maybe Particle
|
destroyAt :: Point2 -> Particle -> Maybe Particle
|
||||||
destroyAt hitp pt = Just $ pt
|
destroyAt hitp pt = Just $ pt
|
||||||
& ptUpdate .~ killBulletUpdate
|
& ptUpdate .~ killParticleUpdate
|
||||||
& ptTrail .:~ hitp
|
& ptTrail .:~ hitp
|
||||||
& ptTimer %~ (min 3 . subtract 1)
|
& ptTimer %~ (min 3 . subtract 1)
|
||||||
|
destroyAt' :: Point2 -> Bullet -> Maybe Bullet
|
||||||
|
destroyAt' hitp pt = Just $ pt
|
||||||
|
& buUpdate .~ killBulletUpdate
|
||||||
|
& buTrail .:~ hitp
|
||||||
|
& buTimer %~ (min 3 . subtract 1)
|
||||||
|
|
||||||
killBulletUpdate :: World -> Particle -> (World,Maybe Particle)
|
killBulletUpdate :: World -> Bullet -> (World,Maybe Bullet)
|
||||||
killBulletUpdate w pt
|
killBulletUpdate w pt
|
||||||
|
| _buTimer pt <= 0 = (w,Nothing)
|
||||||
|
| otherwise = (w
|
||||||
|
, Just $ pt & buTimer -~ 1
|
||||||
|
& buTrail %~ (\(x:xs) -> x:x:xs)
|
||||||
|
)
|
||||||
|
|
||||||
|
killParticleUpdate :: World -> Particle -> (World,Maybe Particle)
|
||||||
|
killParticleUpdate w pt
|
||||||
| _ptTimer pt <= 0 = (w,Nothing)
|
| _ptTimer pt <= 0 = (w,Nothing)
|
||||||
| otherwise = (w
|
| otherwise = (w
|
||||||
, Just $ pt & ptTimer -~ 1
|
, Just $ pt & ptTimer -~ 1
|
||||||
|
|||||||
@@ -84,6 +84,7 @@ cullPoint cfig w p
|
|||||||
extraPics :: Configuration -> World -> Picture
|
extraPics :: Configuration -> World -> Picture
|
||||||
extraPics cfig w = pictures (_decorations w)
|
extraPics cfig w = pictures (_decorations w)
|
||||||
<> concatMapPic drawParticle (_particles w)
|
<> concatMapPic drawParticle (_particles w)
|
||||||
|
<> concatMapPic drawBul (_bullets w)
|
||||||
<> concatMapPic drawBlip (_radarBlips w)
|
<> concatMapPic drawBlip (_radarBlips w)
|
||||||
<> concatMapPic drawFlare (_flares w)
|
<> concatMapPic drawFlare (_flares w)
|
||||||
<> concatMapPic (dbArg _bmDraw) (_positronBeams $ _beams w)
|
<> concatMapPic (dbArg _bmDraw) (_positronBeams $ _beams w)
|
||||||
|
|||||||
@@ -81,6 +81,7 @@ functionalUpdate cfig w = checkEndGame
|
|||||||
. dbArg _worldEvents
|
. dbArg _worldEvents
|
||||||
. updateIMl _modifications _mdUpdate
|
. updateIMl _modifications _mdUpdate
|
||||||
. updateParticles
|
. updateParticles
|
||||||
|
. updateBullets
|
||||||
. updateRadarBlips
|
. updateRadarBlips
|
||||||
. updateFlares
|
. updateFlares
|
||||||
. updateBeams
|
. updateBeams
|
||||||
@@ -212,6 +213,12 @@ updateRadarBlips = radarBlips %~ mapMaybe updateRadarBlip
|
|||||||
updateFlares :: World -> World
|
updateFlares :: World -> World
|
||||||
updateFlares = flares %~ mapMaybe updateFlare
|
updateFlares = flares %~ mapMaybe updateFlare
|
||||||
|
|
||||||
|
{- Apply internal particle updates, delete 'Nothing's. -}
|
||||||
|
updateBullets :: World -> World
|
||||||
|
updateBullets w = updateInstantBullets $ set bullets (catMaybes ps) w'
|
||||||
|
where
|
||||||
|
(w',ps) = mapAccumR (\a b -> _buUpdate b a b) w $ _bullets w
|
||||||
|
|
||||||
{- Apply internal particle updates, delete 'Nothing's. -}
|
{- Apply internal particle updates, delete 'Nothing's. -}
|
||||||
updateParticles :: World -> World
|
updateParticles :: World -> World
|
||||||
updateParticles w = updateInstantParticles $ set particles (catMaybes ps) w'
|
updateParticles w = updateInstantParticles $ set particles (catMaybes ps) w'
|
||||||
@@ -287,6 +294,11 @@ intersectSegSegs' _ _ _ = Nothing
|
|||||||
-- Just
|
-- Just
|
||||||
-- (intersectSegSegss x y ass)
|
-- (intersectSegSegss x y ass)
|
||||||
--intersectSegsSegss _ _ = Nothing
|
--intersectSegsSegss _ _ = Nothing
|
||||||
|
updateInstantBullets :: World -> World
|
||||||
|
updateInstantBullets w = case _instantBullets w of
|
||||||
|
[] -> w
|
||||||
|
ps -> let (w',ps') = mapAccumR (\a b -> _buUpdate b a b) (w {_instantBullets=[]}) ps
|
||||||
|
in updateInstantBullets $ w' & bullets .++~ catMaybes ps'
|
||||||
|
|
||||||
updateInstantParticles :: World -> World
|
updateInstantParticles :: World -> World
|
||||||
updateInstantParticles w = case _instantParticles w of
|
updateInstantParticles w = case _instantParticles w of
|
||||||
|
|||||||
@@ -133,11 +133,11 @@ dirtWallDamage dm wl = case _dmType dm of
|
|||||||
|
|
||||||
wallDamageEffect :: Damage -> Wall -> World -> World
|
wallDamageEffect :: Damage -> Wall -> World -> World
|
||||||
wallDamageEffect dm wl w = case _dmEffect dm of
|
wallDamageEffect dm wl w = case _dmEffect dm of
|
||||||
BounceBullet bt -> w & instantParticles .:~ thebouncer
|
BounceBullet bt -> w & instantBullets .:~ thebouncer
|
||||||
where
|
where
|
||||||
reflectVel = reflVelWall wl (_ptVel bt)
|
reflectVel = reflVelWall wl (_buVel bt)
|
||||||
thebouncer = aBulAt Nothing id (Just (_ptColor bt)) pOut reflectVel (_btDrag bt) (_ptHitEff bt) (_ptWidth bt)
|
thebouncer = aBulAt Nothing id (Just (_buColor bt)) pOut reflectVel (_buDrag bt) (_buHitEff bt) (_buWidth bt)
|
||||||
& ptTimer .~ _ptTimer bt - 1
|
& buTimer .~ _buTimer bt - 1
|
||||||
pOut = p +.+ squashNormalizeV (sp -.- p)
|
pOut = p +.+ squashNormalizeV (sp -.- p)
|
||||||
p = _dmAt dm
|
p = _dmAt dm
|
||||||
sp = _dmFrom dm
|
sp = _dmFrom dm
|
||||||
|
|||||||
Reference in New Issue
Block a user