Remove bullet delay
This commit is contained in:
+19
-24
@@ -21,16 +21,14 @@ import qualified ListHelp as List
|
||||
import Data.Bifunctor
|
||||
|
||||
updateBullet :: World -> Bullet -> (World, Maybe Bullet)
|
||||
updateBullet w bu = case _buDelayFraction bu of
|
||||
1 -> mvBullet 1 w bu
|
||||
x -> mvBullet x w (bu & buDelayFraction .~ 1)
|
||||
updateBullet w bu = mvBullet w bu
|
||||
|
||||
mvBullet :: Float -> World -> Bullet -> (World, Maybe Bullet)
|
||||
mvBullet x w bu
|
||||
mvBullet :: World -> Bullet -> (World, Maybe Bullet)
|
||||
mvBullet w bu
|
||||
| magV (_buVel bu) < 1 || _buTimer bu <= 0 = (endspawn w, Nothing)
|
||||
| otherwise =
|
||||
second (fmap updateBulVel)
|
||||
. hitEffFromBul x w
|
||||
. hitEffFromBul w
|
||||
$ applyMagnetsToBul bu w
|
||||
where
|
||||
endspawn = fromMaybe id $ do
|
||||
@@ -139,15 +137,14 @@ makeFlak bu _ w = w & cWorld . lWorld . instantBullets .++~ [f x | x <- xs]
|
||||
g x v = v +.+ x *.* normalizeV (vNormal v)
|
||||
|
||||
hitEffFromBul ::
|
||||
Float ->
|
||||
World ->
|
||||
Bullet ->
|
||||
(World, Maybe Bullet)
|
||||
hitEffFromBul x w bu = case _buEffect bu of
|
||||
PenetrateBullet -> movePenBullet x bu hitstream w
|
||||
hitEffFromBul w bu = case _buEffect bu of
|
||||
PenetrateBullet -> movePenBullet bu hitstream w
|
||||
BounceBullet -> case List.safeHead hitstream of
|
||||
Nothing -> (w, moveBullet x bu)
|
||||
Just (hp, crwl) -> fromMaybe (expireAndDamage x bu hitstream w) $ do
|
||||
Nothing -> (w, moveBullet bu)
|
||||
Just (hp, crwl) -> fromMaybe (expireAndDamage bu hitstream w) $ do
|
||||
dir <- bounceDir (hp, crwl)
|
||||
return
|
||||
( w
|
||||
@@ -158,9 +155,9 @@ hitEffFromBul x w bu = case _buEffect bu of
|
||||
& buTrajectory .~ BasicBulletTrajectory
|
||||
& buTimer -~ 1
|
||||
)
|
||||
DestroyBullet -> expireAndDamage x bu hitstream w
|
||||
DestroyBullet -> expireAndDamage bu hitstream w
|
||||
where
|
||||
ep = sp +.+ x *.* _buVel bu
|
||||
ep = sp +.+ _buVel bu
|
||||
sp = _buPos bu
|
||||
hitstream = thingsHit sp ep w
|
||||
|
||||
@@ -177,20 +174,19 @@ damageThingHit bu (p, crwl) = case crwl of
|
||||
dams = setFromToDams bu p
|
||||
|
||||
expireAndDamage ::
|
||||
Float ->
|
||||
Bullet ->
|
||||
[(Point2, Either Creature Wall)] ->
|
||||
World ->
|
||||
(World, Maybe Bullet)
|
||||
expireAndDamage y bt things w = case List.safeHead things of
|
||||
Nothing -> (w, moveBullet y bt)
|
||||
expireAndDamage bt things w = case List.safeHead things of
|
||||
Nothing -> (w, moveBullet bt)
|
||||
Just x -> (damageThingHit bt x w, destroyAt (fst x) bt)
|
||||
|
||||
moveBullet :: Float -> Bullet -> Maybe Bullet
|
||||
moveBullet x pt =
|
||||
moveBullet :: Bullet -> Maybe Bullet
|
||||
moveBullet pt =
|
||||
Just $
|
||||
pt
|
||||
& buPos %~ (+.+ x *.* _buVel pt)
|
||||
& buPos %~ (+.+ _buVel pt)
|
||||
& buOldPos .~ _buPos pt
|
||||
& buTimer -~ 1
|
||||
|
||||
@@ -205,17 +201,16 @@ destroyAt hitp pt =
|
||||
p = _buPos pt
|
||||
|
||||
movePenBullet ::
|
||||
Float ->
|
||||
Bullet ->
|
||||
[(Point2, Either Creature Wall)] ->
|
||||
World ->
|
||||
(World, Maybe Bullet)
|
||||
movePenBullet x bu hitstream w = case hitstream of
|
||||
[] -> (w, moveBullet x bu)
|
||||
movePenBullet bu hitstream w = case hitstream of
|
||||
[] -> (w, moveBullet bu)
|
||||
((p, crwl) : strm) ->
|
||||
if penThing crwl
|
||||
then first (damageThingHit bu (p, crwl)) $ movePenBullet x bu strm w
|
||||
else expireAndDamage x bu hitstream w
|
||||
then first (damageThingHit bu (p, crwl)) $ movePenBullet bu strm w
|
||||
else expireAndDamage bu hitstream w
|
||||
|
||||
penThing :: Either Creature Wall -> Bool
|
||||
penThing (Left _) = True
|
||||
|
||||
Reference in New Issue
Block a user