Make creature update an external function

This commit is contained in:
2022-07-20 01:22:17 +01:00
parent db44d5d6ce
commit 1f79fe157f
31 changed files with 562 additions and 462 deletions
+68
View File
@@ -0,0 +1,68 @@
module Dodge.Projectile where
--createProjectile :: ProjectileType -> Item -> Creature -> World -> World
--createProjectile pt = case pt of
-- ShellType -> fireShell
--
--fireShell :: Item -> Creature -> World -> World
--fireShell it cr = makeShell it cr $ \pj -> pjEffAtTime 35 (trySpinByCID (_crID cr) spinamount) pj
-- . pjThrust thrustdelay pj
-- . reduceSpinBy (1-fromIntegral spindrag*2 / 200) pj
-- . decTimMvVel pj
-- . moveShell pj
-- where
-- params = _itParams it
-- spindrag = _shellSpinDrag params
-- spinamount = _shellSpinAmount params
-- thrustdelay = _shellThrustDelay params
--
--makeShell :: Item -> Creature -> (Projectile -> World -> World) -> World -> World
--makeShell it cr theupdate w = w & props %~ IM.insert i Shell
-- { _prPos = pos
-- , _pjZ = 20
-- , _pjStartPos = pos
-- , _pjVel = rotateV dir (V2 1 0)
-- , _pjID = i
-- , _pjUpdate = theupdate
-- , _pjAcc = rotateV dir (V2 3 0)
-- , _pjDir = dir
-- , _pjSpin = 0
-- , _pjPayload = _amPayload $ _laAmmoType am
-- , _pjTimer = 50
-- }
-- where
-- i = IM.newKey $ _props w
-- dir = _crDir cr
-- pos = _crPos cr +.+ rotateV dir (V2 (_crRad cr + 1) 0)
-- am = _itConsumption it
--
--moveShell :: Prop -- ^ Projectile id
-- -> World
-- -> World
--moveShell pj w
-- | time > 40 = if circOnSomeWall oldPos 4 w
-- then doExplode
-- else w
-- | anythingHitCirc 2 oldPos newPos w = doExplode
-- | time > -300 = w
-- | otherwise = doExplode
-- where
-- time = _pjTimer pj
-- doExplode = w
-- & usePayload (_pjPayload pj) oldPos
-- & stopSoundFrom (ShellSound i)
-- & props %~ IM.delete i
-- i = _pjID pj
-- oldPos = _prPos pj
-- vel = _pjVel pj
-- newPos = oldPos +.+ vel
--
--usePjCreation :: Item -> Creature -> World -> World
--usePjCreation it = createProjectile (_amPjCreation (_laAmmoType (_itConsumption it))) it
--
--usePjCreationX :: Int -> Item -> Creature -> World -> World
--usePjCreationX i it cr = foldr f
-- (_amPjCreation (_laAmmoType (_itConsumption it)) it cr)
-- [1..i-1]
-- where
-- f n = (. _amPjCreation (_laAmmoType (_itConsumption it)) it (cr & crDir +~ (2*pi*fromIntegral n / fromIntegral i)))