Start making projectile update function rather than folded list
This commit is contained in:
@@ -32,24 +32,26 @@ createShell mdetonator mscreen pjtype payload muz cr w = w
|
||||
, _pjPayload = payload
|
||||
, _pjTimer = lifespan
|
||||
, _pjUpdates =
|
||||
[ CollisionEffectPU mdetonator mscreen
|
||||
[ CollisionEffectPU
|
||||
, TimePU
|
||||
, StartSpinPU (lifespan - 15) (_crID cr) spinamount
|
||||
, RemoteDirectionPU (lifespan - thrustdelay) 0
|
||||
, ReduceSpinPU (1 - spindrag * 2 / 200)
|
||||
] <> thrustorgrav
|
||||
, _pjType = pjtype
|
||||
, _pjDetonatorID = mdetonator
|
||||
, _pjScreenID = mscreen
|
||||
}
|
||||
where
|
||||
speed = case pjtype of
|
||||
Grenade -> 4
|
||||
Grenade {} -> 4
|
||||
Rocket{} -> 1
|
||||
lifespan = case pjtype of
|
||||
Grenade -> 150
|
||||
Rocket{} -> 350
|
||||
RetiredProjectile -> 0
|
||||
lifespan = 350
|
||||
thrustorgrav = case pjtype of
|
||||
Grenade -> [ApplyGravityPU]
|
||||
Grenade {}-> [ApplyGravityPU]
|
||||
Rocket{} -> [ThrustPU (lifespan - thrustdelay) 0]
|
||||
RetiredProjectile -> []
|
||||
spindrag = 1
|
||||
spinamount = 2
|
||||
thrustdelay = 20
|
||||
|
||||
@@ -26,10 +26,10 @@ updateProjectile pj w = foldl' (flip $ upProjectile pj) w (_pjUpdates pj)
|
||||
|
||||
upProjectile :: Projectile -> ProjectileUpdate -> World -> World
|
||||
upProjectile pj pu = case pu of
|
||||
CollisionEffectPU mdetonatorid mscreenid ->
|
||||
CollisionEffectPU ->
|
||||
shellCollisionCheck
|
||||
mdetonatorid
|
||||
mscreenid
|
||||
(pj ^. pjDetonatorID)
|
||||
(pj ^. pjScreenID)
|
||||
pj
|
||||
TimePU -> decTimMvVel pj
|
||||
ThrustPU st et
|
||||
@@ -79,7 +79,7 @@ applyGravityPU pj w
|
||||
| otherwise = x * 0.9
|
||||
newz = pj ^. pjZ + pj ^. pjZVel
|
||||
|
||||
--shellCollisionCheck :: (Projectile -> World -> World) -> Projectile -> World -> World
|
||||
-- consider using thingHit, pushing any hit creature back
|
||||
shellCollisionCheck ::
|
||||
Maybe (NewInt ItmInt) ->
|
||||
Maybe (NewInt ItmInt) ->
|
||||
@@ -174,12 +174,9 @@ decTimMvVel :: Projectile -> World -> World
|
||||
decTimMvVel pj =
|
||||
cWorld . lWorld . projectiles . ix (_pjID pj)
|
||||
%~ ( (pjTimer -~ 1)
|
||||
. (pjPos %~ (+.+ vel))
|
||||
. (pjDir +~ rot)
|
||||
. (pjPos +~ _pjVel pj)
|
||||
. (pjDir +~ _pjSpin pj)
|
||||
)
|
||||
where
|
||||
rot = _pjSpin pj
|
||||
vel = _pjVel pj
|
||||
|
||||
explodeShell ::
|
||||
Maybe (NewInt ItmInt) ->
|
||||
|
||||
Reference in New Issue
Block a user