Remove ssaTri, bullet movement is broken

This commit is contained in:
2021-12-15 17:34:20 +00:00
parent dccacd9d22
commit adab32bf68
13 changed files with 74 additions and 213 deletions
+14 -14
View File
@@ -28,7 +28,7 @@ bulHitCr bt p cr w
| otherwise = addDamage . bulletHitSound p $ w
where
sp = head $ _btTrail' bt
bulVel = _btVel' bt
bulVel = _ptVel bt
ep = sp +.+ bulVel
mvDams = [ PushDam 1 $ 2 *.* bulVel ]
addDamage = creatures . ix cid . crState . crDamage %~ ((Piercing 100 sp p ep : mvDams) ++ )
@@ -46,7 +46,7 @@ bulBounceArmCr' bt p cr w
| otherwise = addDamage . bulletHitSound p $ w
where
sp = head $ _btTrail' bt
bulVel = _btVel' bt
bulVel = _ptVel bt
ep = sp +.+ bulVel
mvDams = [ PushDam 1 $ 2 *.* bulVel ]
addDamage = creatures . ix cid . crState . crDamage %~ ((Piercing 100 sp p ep : mvDams) ++ )
@@ -77,9 +77,9 @@ bulPenCr' bt p cr w
(d1,_) = randomR (-0.7,0.7) $ _randGen w
cid = _crID cr
sp = head $ _btTrail' bt
ep = sp +.+ _btVel' bt
ep = sp +.+ _ptVel bt
addPiercer = over particles (piercer :)
piercer = (aGenBulAt (Just cid) p (_btVel' bt) (_btDrag bt)
piercer = (aGenBulAt (Just cid) p (_ptVel bt) (_btDrag bt)
(_btHitEffect' bt) (_btWidth' bt)
) {_btTimer' = _btTimer' bt - 1}
{- | Heavy bullet effects when hitting creature:
@@ -100,7 +100,7 @@ hvBulHitCr bt p cr w
(d1,_) = randomR (-0.7,0.7) $ _randGen w
cid = _crID cr
sp = head $ _btTrail' bt
ep = sp +.+ _btVel' bt
ep = sp +.+ _ptVel bt
{- | Create a flamelet when hitting a creature. -}
bulIncCr :: Particle -> Point2 -> Creature -> World -> World
bulIncCr bt p cr w
@@ -112,7 +112,7 @@ bulIncCr bt p cr w
where
cid = _crID cr
sp = head $ _btTrail' bt
ep = sp +.+ _btVel' bt
ep = sp +.+ _ptVel bt
v = evalState (randInCirc 1) $ _randGen w
incFlamelets = over worldEvents $ (.) (makeFlameletTimed p 20 v Nothing 3 20)
{- | Creates a shockwave when hitting a creature. -}
@@ -124,23 +124,23 @@ bulConCr bt p cr
where
cid = _crID cr
sp = head $ _btTrail' bt
ep = sp +.+ _btVel' bt
ep = sp +.+ _ptVel bt
{- | Hitting wall effects: create a spark, damage blocks. -}
bulHitWall :: Particle -> Point2 -> Wall -> World -> World
bulHitWall bt p = damageWall (Piercing 100 sp p ep)
where
ep = sp +.+ _btVel' bt
ep = sp +.+ _ptVel bt
sp = head $ _btTrail' bt
{- | Bounce off walls, do damage to blocks. -}
bulBounceWall :: Particle -> Point2 -> Wall -> World -> World
bulBounceWall bt p wl = damageWall (Blunt 50 sp p ep) wl . over worldEvents addBouncer
where
ep = sp +.+ _btVel' bt
ep = sp +.+ _ptVel bt
sp = head $ _btTrail' bt
pOut = p +.+ squashNormalizeV (sp -.- p)
bouncer = (aGenBulAt Nothing pOut reflectVel 0.5 (_btHitEffect' bt) (_btWidth' bt)
) {_btTimer' = _btTimer' bt - 1}
reflectVel = reflVelWall wl (_btVel' bt)
reflectVel = reflVelWall wl (_ptVel bt)
addBouncer = ( over particles (bouncer : ) . )
-- the hack is to get around the fact that the particles list gets reset after
-- all projectiles in it are checked, so we cannot add to it as we accumulate over
@@ -155,11 +155,11 @@ bulIncWall
-> World
bulIncWall bt p wl = damageWall (Blunt 50 sp p ep) wl . incFlamelets
where
ep = sp +.+ _btVel' bt
ep = sp +.+ _ptVel bt
sp = head $ _btTrail' bt
pOut = p +.+ squashNormalizeV (sp -.- p)
wallV = uncurry (-.-) (_wlLine wl)
reflectVel = squashNormalizeV $ reflectIn wallV (_btVel' bt)
reflectVel = squashNormalizeV $ reflectIn wallV (_ptVel bt)
incFlamelets = over worldEvents $ (.) (makeFlameletTimed pOut 20 reflectVel Nothing 3 20)
{- | Create a shockwave on wall-}
bulConWall
@@ -171,7 +171,7 @@ bulConWall
bulConWall bt p wl = damageWall (Blunt 10 sp p ep) wl .
over worldEvents ( makeShockwaveAt [] p 15 4 1 white . )
where
ep = sp +.+ _btVel' bt
ep = sp +.+ _ptVel bt
sp = head $ _btTrail' bt
hvBulHitWall
@@ -184,7 +184,7 @@ hvBulHitWall bt p wl w = damageWall (Piercing 200 sp p ep) wl
. damageWall (Blunt 100 sp p ep) wl
$ set randGen g $ foldr ($) w (sparks pOut sv)
where
ep = sp +.+ _btVel' bt
ep = sp +.+ _ptVel bt
sp = head $ _btTrail' bt
pOut = p +.+ squashNormalizeV (sp -.- p)
(a, g) = randomR (-0.2,0.2) $ _randGen w
+5 -5
View File
@@ -23,7 +23,7 @@ aGenBulAt
aGenBulAt maycid pos vel drag hiteff width = BulletPt
{ _ptDraw = drawBul
, _ptUpdate = mvBullet
, _btVel' = vel
, _ptVel = vel
, _btDrag = drag
, _btColor' = V4 2 2 2 2
, _btTrail' = [pos]
@@ -44,7 +44,7 @@ aDelayedBulAt
aDelayedBulAt vfact maycid pos vel drag hiteff width = BulletPt
{ _ptDraw = drawBul
, _ptUpdate = \w -> resetVel . mvBullet w
, _btVel' = vfact *.* vel
, _ptVel = vfact *.* vel
, _btDrag = drag
, _btColor' = V4 2 2 2 2
, _btTrail' = [pos]
@@ -54,7 +54,7 @@ aDelayedBulAt vfact maycid pos vel drag hiteff width = BulletPt
, _btHitEffect' = hiteff
}
where
resetVel = second $ fmap $ (ptUpdate .~ mvBullet) . (btVel' .~ vel)
resetVel = second $ fmap $ (ptUpdate .~ mvBullet) . (ptVel .~ vel)
aCurveBulAt
:: Maybe Int -- ^ Pass-through creature id
@@ -68,7 +68,7 @@ aCurveBulAt
aCurveBulAt maycid col pos control targ hiteff width = BulletPt
{ _ptDraw = drawBul
, _ptUpdate = \w -> mvBullet w . setVel
, _btVel' = V2 0 0
, _ptVel = V2 0 0
, _btDrag = 1
, _btColor' = col
, _btTrail' = [pos]
@@ -78,5 +78,5 @@ aCurveBulAt maycid col pos control targ hiteff width = BulletPt
, _btHitEffect' = hiteff
}
where
setVel pt = pt & btVel' .~ bf (fromIntegral $ _btTimer' pt - 1) -.- bf (fromIntegral $ _btTimer' pt)
setVel pt = pt & ptVel .~ bf (fromIntegral $ _btTimer' pt - 1) -.- bf (fromIntegral $ _btTimer' pt)
bf t = bQuadToF (pos,control,targ) $ (100 - t) * 0.05
+4 -4
View File
@@ -1,4 +1,4 @@
{-# LANGUAGE TupleSections #-}
--{-# LANGUAGE TupleSections #-}
{- Bullet update. -}
module Dodge.Particle.Bullet.Update
( mvBullet
@@ -15,15 +15,15 @@ import Control.Lens
{- Update for a generic bullet. -}
mvBullet :: World -> Particle -> (World, Maybe Particle)
mvBullet w bt'
| t <= 0 || magV (_btVel' bt) < 1 = (w,Nothing)
| t <= 0 || magV (_ptVel bt) < 1 = (w,Nothing)
| otherwise = second (fmap dodrag) $
hiteff bt (thingsHitExceptCr mcr p (p +.+ vel) w) w
where
bt = foldr (\mg b -> _mgField mg mg b) bt' $ _magnets w
dodrag = btVel' %~ (drag *.*)
dodrag = ptVel %~ (drag *.*)
drag = _btDrag bt
mcr = _btPassThrough' bt
(p:_) = _btTrail' bt
vel = _btVel' bt
vel = _ptVel bt
hiteff = _btHitEffect' bt
t = _btTimer' bt
+17 -19
View File
@@ -16,30 +16,28 @@ import System.Random
--import Control.Lens
createBarrelSpark :: Point2 -> Float -> Maybe Int -> Int -> Int -> World -> World
createBarrelSpark pos dir maycid time colid w = w
& instantParticles .:~ spark
createBarrelSpark pos dir maycid time colid = instantParticles .:~ BulletPt
{ _ptDraw = drawBul
, _ptUpdate = mvBullet
, _ptVel = rotateV dir (V2 5 0)
, _btDrag = 0.9
, _btColor' = numColor colid
, _btTrail' = [pos]
, _btPassThrough' = maycid
, _btWidth' = 1
, _btTimer' = time
, _btHitEffect' = destroyOnImpact sparkEff noEff
}
where
spark = BulletPt
{ _ptDraw = drawBul
, _ptUpdate = mvBullet
, _btVel' = rotateV dir (V2 5 0)
, _btDrag = 0.9
, _btColor' = numColor colid
, _btTrail' = [pos]
, _btPassThrough' = maycid
, _btWidth' = 1
, _btTimer' = time
, _btHitEffect' = destroyOnImpact sparkEff noEff
}
sparkEff bt p cr = creatures . ix (_crID cr) . crState . crDamage .:~ SparkDam 1 sp p ep
where
where
sp = head (_btTrail' bt)
ep = sp +.+ _btVel' bt
ep = sp +.+ _ptVel bt
colSpark :: Int -> Color -> Point2 -> Float -> World -> World
colSpark = colSpark' 0.7
colSpark' :: Float -> Int -> Color -> Point2 -> Float -> World -> World
colSpark' randDir time col pos baseDir w = w
& worldEvents %~ ( over particles (spark :) . )
& instantParticles .:~ spark
& randGen .~ g
where
(a,g) = randomR (-randDir,randDir) $ _randGen w
@@ -48,7 +46,7 @@ colSpark' randDir time col pos baseDir w = w
{ _ptDraw = drawBul
, _ptUpdate = mvBullet
, _btDrag = 0.9
, _btVel' = rotateV dir (V2 5 0)
, _ptVel = rotateV dir (V2 5 0)
, _btColor' = col
, _btTrail' = [pos]
, _btPassThrough' = Nothing
@@ -59,4 +57,4 @@ colSpark' randDir time col pos baseDir w = w
sparkEff bt p cr = creatures . ix (_crID cr) . crState . crDamage %~ ( SparkDam 1 sp p ep : )
where
sp = head (_btTrail' bt)
ep = sp +.+ _btVel' bt
ep = sp +.+ _ptVel bt