Split bullet spawning and bouncing/penetration
This commit is contained in:
+6
-19
@@ -21,7 +21,6 @@ import Control.Monad.State
|
||||
|
||||
updateBullet :: World -> Bullet -> (World,Maybe Bullet)
|
||||
updateBullet w bu = case _buState bu of
|
||||
DyingBulletState -> (w,Nothing)
|
||||
DelayedBullet x -> mvBullet x w bu
|
||||
_ -> mvBullet 1 w bu
|
||||
|
||||
@@ -54,16 +53,12 @@ useAmmoParams it cr w = w & instantBullets .:~ (_amBullet bultype
|
||||
mvBullet :: Float -> World -> Bullet -> (World, Maybe Bullet)
|
||||
mvBullet x w bt'
|
||||
| t <= 0 || magV (_buVel bt) < 1 = (endspawn w,Nothing)
|
||||
| otherwise = bimap (maybespawn . maybebounce) (fmap dodrag) $
|
||||
| otherwise = bimap maybebounce (fmap dodrag) $
|
||||
hiteff bt hitstream w
|
||||
where
|
||||
endspawn w' = fromMaybe w' $ do
|
||||
partspawn <- bulletSpawn bt'
|
||||
return $ partspawn p w'
|
||||
maybespawn w' = fromMaybe w' $ do
|
||||
(hp,_) <- runIdentity (S.head_ hitstream)
|
||||
partspawn <- bulletSpawn bt'
|
||||
return $ partspawn (hp +.+ normalizeV (_buPos bt' -.- hp)) w'
|
||||
maybebounce = fromMaybe id $ do
|
||||
guard (_buEffect bt' == BounceBullet)
|
||||
(hp,crwl) <- runIdentity (S.head_ hitstream)
|
||||
@@ -101,15 +96,6 @@ bulletSpawn bu = case _buSpawn bu of
|
||||
BulBall IncBall -> Just incBallAt
|
||||
BulBall ConcBall -> Just $ randParticleAt concBall
|
||||
BulBall TeslaBall -> Just makeStaticBall
|
||||
-- where
|
||||
-- dosatate st p w = w'
|
||||
-- &
|
||||
-- where
|
||||
-- (pt,g) = runState do
|
||||
-- partspawn <- bulletSpawn bt'
|
||||
-- let (thepart,g) = runState (partspawn hp) $ _randGen w'
|
||||
-- return $ w' & instantParticles .:~ thepart
|
||||
-- & randGen .~ g
|
||||
|
||||
hitEffFromBul :: Float -> Bullet
|
||||
-> Stream (Of (Point2, Either Creature Wall)) Identity ()
|
||||
@@ -138,10 +124,11 @@ moveBullet x pt = Just $ pt
|
||||
|
||||
destroyAt' :: Point2 -> Bullet -> Maybe Bullet
|
||||
destroyAt' hitp pt = Just $ pt
|
||||
& buState .~ DyingBulletState
|
||||
& buPos .~ hitp
|
||||
& buOldPos .~ _buPos pt
|
||||
& buTimer %~ (min 3 . subtract 1)
|
||||
& buPos .~ hitp +.+ normalizeV (p -.- hitp)
|
||||
& buOldPos .~ p
|
||||
& buVel .~ 0
|
||||
where
|
||||
p = _buPos pt
|
||||
|
||||
--penWalls
|
||||
-- :: HitCreatureEffect'
|
||||
|
||||
Reference in New Issue
Block a user