Replace buggy circle seg intersection with a simpler test

This commit is contained in:
2024-12-26 21:53:18 +00:00
parent 91ba6ee148
commit 0ef28c132e
29 changed files with 528 additions and 332 deletions
+50 -1
View File
@@ -1,5 +1,6 @@
module Dodge.Projectile.Create (
createShell,
createGShell,
) where
import NewInt
@@ -30,7 +31,7 @@ createShell homing mdetonator mscreen payload muz cr w = w
?~ Shell
{ _prjPos = pos
, _prjZ = 20
, _prjStartPos = pos
, _prjZVel = 0
, _prjVel = rotateV dir (V2 1 0) + cr ^. crPos - cr ^. crOldPos
, _prjDraw = homingDrawType homing
, _prjID = i
@@ -65,3 +66,51 @@ createShell homing mdetonator mscreen payload muz cr w = w
i = IM.newKey $ w ^. cWorld . lWorld . projectiles
dir = _crDir cr + _mzRot muz
pos = _crPos cr +.+ rotateV dir (_mzPos muz)
-- assumes the mscreen is in your inventory
createGShell :: ProjectileHoming
-> Maybe (NewInt ItmInt)
-> Maybe (NewInt ItmInt)
-> Payload -> Muzzle -> Creature -> World -> World
createGShell homing mdetonator mscreen payload muz cr w = w
& updatescreen
& updatedetonator
& cWorld . lWorld . projectiles . at i
?~ Shell
{ _prjPos = pos
, _prjZ = 20
, _prjZVel = 5
, _prjVel = rotateV dir (V2 4 0) + cr ^. crPos - cr ^. crOldPos
, _prjDraw = homingDrawType homing
, _prjID = i
, _prjAcc = rotateV dir (V2 3 0)
, _prjDir = dir
, _prjSpin = 0
, _prjPayload = payload
, _prjTimer = 350
, _prjUpdates =
[ CollisionEffectPU (homing ^? phRemoteID) mdetonator mscreen
, TimePU
, StartSpinPU 335 (_crID cr) spinamount
, RemoteDirectionPU (350 - thrustdelay) 0 homing
, ReduceSpinPU (1 - spindrag * 2 / 200)
, ApplyGravityPU
]
}
where
spindrag = 1
spinamount = 2
thrustdelay = 20
updatedetonator = fromMaybe id $ do
screenid <- mdetonator
return $ pointerToItemID screenid . itUse . uaParams
. apLinkedProjectile
?~ i
updatescreen = fromMaybe id $ do
screenid <- homing ^? phRemoteID
return $ pointerToItemID screenid . itUse . uaParams
. apLinkedProjectile
?~ i
i = IM.newKey $ w ^. cWorld . lWorld . projectiles
dir = _crDir cr + _mzRot muz
pos = _crPos cr +.+ rotateV dir (_mzPos muz)