Replace buggy circle seg intersection with a simpler test
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -20,7 +20,7 @@ drawProjectile prj = case _prjDraw prj of
|
||||
drawShell :: Projectile -> SPic
|
||||
drawShell pj =
|
||||
noPic
|
||||
. translateSHz 18
|
||||
. translateSHz (_prjZ pj)
|
||||
. uncurryV translateSHxy (_prjPos pj)
|
||||
$ rotateSH (argV $ _prjAcc pj) shellShape
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ module Dodge.Projectile.Update (
|
||||
updateProjectile,
|
||||
) where
|
||||
|
||||
import Control.Lens
|
||||
import LensHelp
|
||||
import Control.Monad
|
||||
import Data.Foldable
|
||||
import Data.Maybe
|
||||
@@ -42,18 +42,44 @@ upProjectile pu pj = case pu of
|
||||
-- the following requires that this is at the top of the update list, which is
|
||||
-- not ideal
|
||||
DestroyPU _ _ -> cWorld . lWorld . projectiles . ix (_prjID pj) . prjUpdates . ix 0 . pjuTimer -~ 1
|
||||
ApplyGravityPU -> applyGravityPU pj
|
||||
where
|
||||
time = _prjTimer pj
|
||||
act st et = time <= st && time >= et
|
||||
|
||||
applyGravityPU :: Projectile -> World -> World
|
||||
applyGravityPU pj w
|
||||
| newz <= 0 && abs (pj ^. prjZVel) < 1 = w
|
||||
& topj . prjVel %~ decvel
|
||||
& topj . prjSpin %~ decspin
|
||||
| newz < 0 = w & topj . prjZ .~ 0
|
||||
& topj . prjZVel %~ bouncez
|
||||
& topj . prjVel %~ decvel
|
||||
& topj . prjSpin %~ decspin
|
||||
& soundStart (ShellSound (pj ^. prjID)) (pj ^. prjPos) click1S Nothing
|
||||
| otherwise = w & topj . prjZ .~ newz
|
||||
& topj . prjZVel -~ 0.5
|
||||
where
|
||||
topj = cWorld . lWorld . projectiles . ix (pj ^. prjID)
|
||||
bouncez z | z < -1 = -0.5 * z
|
||||
| otherwise = 0
|
||||
decvel v
|
||||
| magV v > 1 = rotateV (5 * pj ^. prjSpin) $ 0.8 * v
|
||||
| otherwise = 0
|
||||
decspin x
|
||||
| abs x < 0.01 = 0
|
||||
| otherwise = x * 0.9
|
||||
newz = pj ^. prjZ + pj ^. prjZVel
|
||||
|
||||
--shellCollisionCheck :: (Projectile -> World -> World) -> Projectile -> World -> World
|
||||
shellCollisionCheck :: Maybe (NewInt ItmInt)
|
||||
-> Maybe (NewInt ItmInt)
|
||||
-> Maybe (NewInt ItmInt)
|
||||
-> Projectile -> World -> World
|
||||
shellCollisionCheck controlid detid screenid pj w
|
||||
| time > 330 && circOnSomeWall oldPos 4 w = g
|
||||
| time <= 330 && anythingHitCirc 2 oldPos newPos w = g
|
||||
-- | time > 330 && circOnSomeWall oldPos 4 w = g
|
||||
-- | time <= 330 && anythingHitCirc 2 oldPos newPos w = g
|
||||
| anythingHitCirc 2 oldPos newPos w = g
|
||||
| time <= 0 = g
|
||||
| otherwise = w
|
||||
where
|
||||
|
||||
Reference in New Issue
Block a user