Rename (indexed) particles to projectiles

This commit is contained in:
jgk
2021-03-23 14:03:00 +01:00
parent 941fef134d
commit 885fa4a67e
11 changed files with 245 additions and 251 deletions
+102 -102
View File
@@ -534,7 +534,7 @@ multGun = defaultGun
, _wpFire = shootWithSound (fromIntegral shotgunSound)
. withRecoil 200
. withMuzFlare
$ numVelWthHitEff 5 (50,0) 4 bulletEffect'
$ numVelWthHitEff 5 (50,0) 5 bulletEffect'
, _wpSpread = spreadGunSpread
, _wpRange = 20
, _itFloorPict = onLayer FlItLayer $ multGunPic
@@ -664,7 +664,7 @@ aTeslaArc cid w = aTeslaArc' cid
aTeslaArc' :: Int -> World -> World
aTeslaArc' cid w =
flareAt' cyan 0.03 0.1 (pos +.+ 5 *.* unitVectorAtAngle dir)
$ over particles (IM.insert i (makeTeslaArcAt i pos dir))
$ over projectiles (IM.insert i (makeTeslaArcAt i pos dir))
$ set randGen g w
where cr = (_creatures w IM.! cid)
i = newParticleKey w
@@ -690,7 +690,7 @@ aTractorBeam :: Int -> Int -> World -> World
aTractorBeam col cid w
= set (creatures . ix cid . crInv . ix itRef . wpFire)
(shoot $ aTractorBeam ((col + 1) `mod` 10))
$ over particles (IM.insert i (tractorBeamAt col i pos dir)) w
$ over projectiles (IM.insert i (tractorBeamAt col i pos dir)) w
where i = newParticleKey w
cr = (_creatures w IM.! cid)
pos = _crPos cr +.+ ((_crRad cr +10) *.* unitVectorAtAngle dir)
@@ -700,14 +700,14 @@ aTractorBeam col cid w
aRocket :: Int -> World -> World
aRocket cid w
= soundOnce (fromIntegral launcherSound)
$ over particles (IM.insert i (makeShellAt i cid pos dir)) w
$ over projectiles (IM.insert i (makeShellAt i cid pos dir)) w
where i = newParticleKey w
cr = (_creatures w IM.! cid)
pos = _crPos cr +.+ ((_crRad cr +1) *.* unitVectorAtAngle dir)
dir = _crDir cr
makeShellAt :: Int -> Int -> Point2 -> Float -> Particle
makeShellAt i cid pos dir = Particle
makeShellAt :: Int -> Int -> Point2 -> Float -> Projectile
makeShellAt i cid pos dir = Projectile
{ _ptPos = pos
, _ptStartPos = pos
, _ptVel = rotateV dir (1,0)
@@ -719,39 +719,39 @@ makeShellAt i cid pos dir = Particle
moveShell :: Int -> Int -> Int -> Float -> Point2 -> World -> World
moveShell time i cid rot accel w
| time > 40 = if circOnSomeWall oldPos 4 w
then shellExplosionAt oldPos $ over particles (IM.delete i) w
else over (particles . ix i . ptPos) (+.+ vel)
$ set (particles . ix i . ptPict) piclow
$ set (particles . ix i . ptUpdate)
then shellExplosionAt oldPos $ over projectiles (IM.delete i) w
else over (projectiles . ix i . ptPos) (+.+ vel)
$ set (projectiles . ix i . ptPict) piclow
$ set (projectiles . ix i . ptUpdate)
(moveShell (time-1) i cid rot (rotateV rot accel))
w
| time == 35 = case thingHit of
Just p -> shellExplosionAt oldPos
$ over particles (IM.delete i) w
Nothing -> over (particles . ix i . ptPos) (+.+ vel)
$ set (particles . ix i . ptPict) pic
$ set (particles . ix i . ptUpdate)
$ over projectiles (IM.delete i) w
Nothing -> over (projectiles . ix i . ptPos) (+.+ vel)
$ set (projectiles . ix i . ptPict) pic
$ set (projectiles . ix i . ptUpdate)
(moveShell (time-1) i cid spin accel)
w
| time >= 20 = case thingHit of
Just p -> shellExplosionAt oldPos
$ over particles (IM.delete i) w
Nothing -> over (particles . ix i . ptPos) (+.+ vel)
$ set (particles . ix i . ptPict) pic
$ set (particles . ix i . ptUpdate)
$ over projectiles (IM.delete i) w
Nothing -> over (projectiles . ix i . ptPos) (+.+ vel)
$ set (projectiles . ix i . ptPict) pic
$ set (projectiles . ix i . ptUpdate)
(moveShell (time-1) i cid rot (rotateV rot accel))
w
| time > -99
= case thingHit of
Just p -> shellExplosionAt oldPos
$ stopSoundFrom (ShellSound i)
$ over particles (IM.delete i) w
Nothing -> over (particles . ix i . ptPos) (+.+ vel)
$ over projectiles (IM.delete i) w
Nothing -> over (projectiles . ix i . ptPos) (+.+ vel)
$ set randGen g
$ set (particles . ix i . ptPict) pic
$ set (particles . ix i . ptUpdate)
$ set (projectiles . ix i . ptPict) pic
$ set (projectiles . ix i . ptUpdate)
(moveShell (time-1) i cid rot (rotateV rot accel))
$ over (particles . ix i . ptVel) (\v -> accel +.+ frict *.* v)
$ over (projectiles . ix i . ptVel) (\v -> accel +.+ frict *.* v)
$ soundFrom (ShellSound i) (fromIntegral smokeTrailSound) (1) 250
$ makeFlameletTimed oldPos
(0.5 *.* rotateV (pi+sparkD) accel) (levLayer UPtLayer) Nothing 3 20
@@ -762,16 +762,16 @@ moveShell time i cid rot accel w
| time > -200 = case thingHit of
Just p -> shellExplosionAt oldPos
$ stopSoundFrom (ShellSound i)
$ over particles (IM.delete i) w
Nothing -> over (particles . ix i . ptPos) (+.+ vel)
$ set (particles . ix i . ptPict) pic
$ set (particles . ix i . ptUpdate)
$ over projectiles (IM.delete i) w
Nothing -> over (projectiles . ix i . ptPos) (+.+ vel)
$ set (projectiles . ix i . ptPict) pic
$ set (projectiles . ix i . ptUpdate)
(moveShell (time-1) i cid rot (rotateV rot accel))
w
| otherwise = shellExplosionAt oldPos
$ stopSoundFrom (ShellSound i)
$ over particles (IM.delete i) w
where pt = _particles w IM.! i
$ over projectiles (IM.delete i) w
where pt = _projectiles w IM.! i
oldPos = _ptPos pt
vel = _ptVel pt
newPos = oldPos +.+ vel
@@ -813,8 +813,8 @@ remoteShellPic i | rem (i+200) 20 < 9 = polygon [(-6,4),(-6,-4),(6,-4),(8,0),(6,
shellExplosionAt = makeExplosionAt
tractorBeamAt :: Int -> Int -> Point2 -> Float -> Particle
tractorBeamAt colID i pos dir = Particle
tractorBeamAt :: Int -> Int -> Point2 -> Float -> Projectile
tractorBeamAt colID i pos dir = Projectile
{ _ptPos = pos
, _ptStartPos = p'
, _ptVel = d
@@ -1003,8 +1003,8 @@ reflect :: Float -> Float -> Float
reflect a b = a + 2*(a-b)
moveGrenade :: Int -> Float -> Int -> World -> World
moveGrenade 0 dir pID w = over particles (IM.delete pID)
$ makeExplosionAt (_ptPos (_particles w IM.! pID))
moveGrenade 0 dir pID w = over projectiles (IM.delete pID)
$ makeExplosionAt (_ptPos (_projectiles w IM.! pID))
-- $ set (pointToItem (_itemPositions w IM.! wpID) . itEquipPict)
-- (drawWeapon $ grenadePic 50)
w
@@ -1013,17 +1013,17 @@ moveGrenade time dir pID w
Just _ -> soundOnce (fromIntegral tapQuiet) updatedWorld
_ -> updatedWorld
where
updatedWorld = updateV $ set (particles . ix pID . ptPos) finalPos
$ set (particles.ix pID.ptPict)
updatedWorld = updateV $ set (projectiles . ix pID . ptPos) finalPos
$ set (projectiles .ix pID.ptPict)
(onLayer PtLayer $ uncurry translate newPos
$ rotate dir $ grenadePic time)
$ set (particles.ix pID.ptUpdate) (moveGrenade (time-1) dir pID) w
pt = _particles w IM.! pID
$ set (projectiles .ix pID.ptUpdate) (moveGrenade (time-1) dir pID) w
pt = _projectiles w IM.! pID
oldPos = _ptPos pt
newPos = _ptVel pt +.+ oldPos
hitWl = collideCircWalls' oldPos newPos 4 $ wallsNearPoint newPos w
finalPos = fromMaybe newPos (fmap fst hitWl)
setV v = set (particles.ix pID.ptVel) v
setV v = set (projectiles .ix pID.ptVel) v
updateV = fromMaybe id (fmap (setV.snd) hitWl)
pointToItem (InInv cid invid) = creatures . ix cid . crInv . ix invid
@@ -1035,15 +1035,15 @@ retireRemoteRocket itid 0 ptid w
(0,0)
$ set (pointToItem (_itemPositions w IM.! itid) . wpFire)
fireRemoteLauncher
(w & particles %~ IM.delete ptid)
retireRemoteRocket itid t ptid w = setScope w & particles . ix ptid . ptUpdate .~ retireRemoteRocket itid (t-1) ptid
(w & projectiles %~ IM.delete ptid)
retireRemoteRocket itid t ptid w = setScope w & projectiles . ix ptid . ptUpdate .~ retireRemoteRocket itid (t-1) ptid
where
setScope w' = case _itemPositions w' IM.! itid of
InInv cid invid
-> w' & creatures . ix cid . crInv . ix invid . itAttachment
. _Just . scopePos .~ (pos -.- _crPos (_creatures w' IM.! cid))
_ -> w'
pos = fromMaybe (0,0) $ w ^? particles . ix ptid . ptPos
pos = fromMaybe (0,0) $ w ^? projectiles . ix ptid . ptPos
retireRemoteBomb :: Int -> Int -> Int -> World -> World
retireRemoteBomb itid 0 ptid w
@@ -1053,22 +1053,22 @@ retireRemoteBomb itid 0 ptid w
basicItZoom
$ set (pointToItem (_itemPositions w IM.! itid) . twFire)
throwRemoteBomb
(w & particles %~ IM.delete ptid)
(w & projectiles %~ IM.delete ptid)
retireRemoteBomb itid t ptid w
= setScope w & particles . ix ptid . ptUpdate .~ retireRemoteBomb itid (t-1) ptid
= setScope w & projectiles . ix ptid . ptUpdate .~ retireRemoteBomb itid (t-1) ptid
where
setScope w' = case _itemPositions w' IM.! itid of
InInv cid invid
-> w' & creatures . ix cid . crInv . ix invid . itAttachment
. _Just . scopePos .~ (pos -.- _crPos (_creatures w' IM.! cid))
_ -> w'
pos = fromMaybe (0,0) $ w ^? particles . ix ptid . ptPos
pos = fromMaybe (0,0) $ w ^? projectiles . ix ptid . ptPos
moveRemoteBomb :: Int -> Int -> Int -> World -> World
moveRemoteBomb itid time pID w
| time < -4 = setScope
$ updatePicture
$ set (particles.ix pID.ptUpdate) (moveRemoteBomb itid (f time) pID)
$ set (projectiles .ix pID.ptUpdate) (moveRemoteBomb itid (f time) pID)
w
| time < 2
= case hitWl of
@@ -1080,9 +1080,9 @@ moveRemoteBomb itid time pID w
_ -> updatedWorld
where
updatedWorld
= updateV $ set (particles . ix pID . ptPos) finalPos
= updateV $ set (projectiles . ix pID . ptPos) finalPos
$ updatePicture
$ set (particles.ix pID.ptUpdate) (moveRemoteBomb itid (time-1) pID)
$ set (projectiles .ix pID.ptUpdate) (moveRemoteBomb itid (time-1) pID)
$ setScope
w
setScope w' = case _itemPositions w' IM.! itid of
@@ -1092,7 +1092,7 @@ moveRemoteBomb itid time pID w
& creatures . ix cid . crInv . ix invid . itZoom
.~ (basicItZoom {_itAimZoomMax = 0.5, _itAimZoomMin = 0.5})
_ -> w'
pt = _particles w IM.! pID
pt = _projectiles w IM.! pID
oldPos = _ptPos pt
newPos = _ptVel pt +.+ oldPos
-- this is hacky, should use a version of collidePointWalls' that collides
@@ -1100,12 +1100,12 @@ moveRemoteBomb itid time pID w
invShift x = x -.- 5 *.* normalizeV (_ptVel pt)
hitWl = collideCircWalls' oldPos newPos 4 $ wallsNearPoint newPos w
finalPos = fromMaybe newPos (fmap (invShift . fst) hitWl)
setV v = set (particles.ix pID.ptVel) v
setV v = set (projectiles .ix pID.ptVel) v
updateV = fromMaybe id (fmap (setV.snd) hitWl)
halfV = over (particles . ix pID . ptVel) (\v -> 0.5 *.* v)
halfV = over (projectiles . ix pID . ptVel) (\v -> 0.5 *.* v)
f x | x < -369 = -10
| otherwise = x - 1
updatePicture = set (particles . ix pID.ptPict)
updatePicture = set (projectiles . ix pID.ptPict)
(onLayer PtLayer $ uncurry translate newPos
$ remoteBombPic time)
. lowLightDirected red 0.1 newPos
@@ -1196,9 +1196,9 @@ withThickSmoke eff cid w = eff cid $ foldr ($) w smokeGen
makeThinSmokeAt :: Color -> Point2 -> Float -> Int -> Point2 -> World -> World
makeThinSmokeAt col vel scal time p w = over particles (IM.insert n smP) w
makeThinSmokeAt col vel scal time p w = over projectiles (IM.insert n smP) w
where n = newParticleKey w
smP = Particle
smP = Projectile
{ _ptPos = p
, _ptStartPos = p
, _ptVel = vel
@@ -1210,22 +1210,22 @@ makeThinSmokeAt col vel scal time p w = over particles (IM.insert n smP) w
moveThinSmoke :: Color -> Float -> Int -> Int -> World -> World
moveThinSmoke col scal time i w
| time > 0
= set (particles . ix i . ptPict) pic
. set (particles . ix i . ptUpdate) (moveThinSmoke col scal (time-1) i)
. set (particles . ix i . ptPos) newPos
= set (projectiles . ix i . ptPict) pic
. set (projectiles . ix i . ptUpdate) (moveThinSmoke col scal (time-1) i)
. set (projectiles . ix i . ptPos) newPos
. setVel
$ w
| time > -10
= set (particles . ix i . ptPict) pi1
. set (particles . ix i . ptUpdate) (moveThinSmoke col scal (time-1) i)
. set (particles . ix i . ptPos) newPos
= set (projectiles . ix i . ptPict) pi1
. set (projectiles . ix i . ptUpdate) (moveThinSmoke col scal (time-1) i)
. set (projectiles . ix i . ptPos) newPos
. setVel
$ w
| otherwise
= over particles (IM.delete i) w
where oldPos = _ptPos $ _particles w IM.! i
newPos = oldPos +.+ (_ptVel $ _particles w IM.! i)
setVel = over (particles . ix i . ptVel) $ (*.*) 0.99
= over projectiles (IM.delete i) w
where oldPos = _ptPos $ _projectiles w IM.! i
newPos = oldPos +.+ (_ptVel $ _projectiles w IM.! i)
setVel = over (projectiles . ix i . ptVel) $ (*.*) 0.99
pic = onLayer PtLayer $ uncurry translate newPos $ color (withAlpha 0.1 col) $ circleSolid scal
pi1 = onLayer PtLayer $ uncurry translate newPos
$ color (withAlpha (0.1 + fromIntegral time /100) col)
@@ -1389,9 +1389,9 @@ remoteBomb = defaultThrowable
throwGrenade :: Int -> Int -> World -> World
throwGrenade fuseTime n w = setWp $ removePict $ over particles addG $ set randGen g w
throwGrenade fuseTime n w = setWp $ removePict $ over projectiles addG $ set randGen g w
where addG = IM.insert i
$ Particle { _ptPos = p
$ Projectile { _ptPos = p
, _ptStartPos = p
, _ptVel = v
, _ptPict = onLayer PtLayer $ uncurry translate p $ grenadePic 0
@@ -1441,13 +1441,13 @@ grenadePic x = pictures [ color (dark $ dark green) $ circleSolid 5
fireRemoteLauncher :: Int -> World -> World
fireRemoteLauncher cid w = setLocation $ resetFire $ resetName
$ soundOnce (fromIntegral launcherSound)
$ over particles remRocket w
$ over projectiles remRocket w
where
i = newKey $ _particles w
i = newKey $ _projectiles w
cr = _creatures w IM.! cid
dir = _crDir cr
pos = _crPos cr +.+ rotateV dir (_crRad cr + 1,0)
remRocket = IM.insert i $ Particle { _ptPos = pos
remRocket = IM.insert i $ Projectile { _ptPos = pos
, _ptStartPos = pos
, _ptVel = rotateV dir (1,0)
, _ptPict = blank
@@ -1470,17 +1470,17 @@ moveRemoteShell :: Int -> Int -> Int -> Int -> Float -> World -> World
moveRemoteShell time i cid itid dir w
| time > 40 = if circOnSomeWall oldPos 4 w
then doExplosion w
else over (particles . ix i . ptPos) (+.+ vel)
$ set (particles . ix i . ptPict) piclow
$ set (particles . ix i . ptUpdate)
else over (projectiles . ix i . ptPos) (+.+ vel)
$ set (projectiles . ix i . ptPict) piclow
$ set (projectiles . ix i . ptUpdate)
(moveRemoteShell (time-1) i cid itid newdir)
$ setScope
w
| time >= 20 = case thingHit of
Just p -> doExplosion w
Nothing -> over (particles . ix i . ptPos) (+.+ vel)
$ set (particles . ix i . ptPict) pic
$ set (particles . ix i . ptUpdate)
Nothing -> over (projectiles . ix i . ptPos) (+.+ vel)
$ set (projectiles . ix i . ptPict) pic
$ set (projectiles . ix i . ptUpdate)
(moveRemoteShell (time-1) i cid itid newdir)
$ setScope
w
@@ -1489,12 +1489,12 @@ moveRemoteShell time i cid itid dir w
Just p -> doExplosion
$ stopSoundFrom (ShellSound i)
w
Nothing -> over (particles . ix i . ptPos) (+.+ vel)
Nothing -> over (projectiles . ix i . ptPos) (+.+ vel)
$ set randGen g
$ set (particles . ix i . ptPict) pic
$ set (particles . ix i . ptUpdate)
$ set (projectiles . ix i . ptPict) pic
$ set (projectiles . ix i . ptUpdate)
(moveRemoteShell (time-1) i cid itid newdir)
$ over (particles . ix i . ptVel) (\v -> accel +.+ frict *.* v)
$ over (projectiles . ix i . ptVel) (\v -> accel +.+ frict *.* v)
$ soundFrom (ShellSound i) (fromIntegral smokeTrailSound) (1) 250
$ smokeGen
$ makeFlameletTimed oldPos
@@ -1507,16 +1507,16 @@ moveRemoteShell time i cid itid dir w
Just p -> doExplosion
$ stopSoundFrom (ShellSound i)
w
Nothing -> over (particles . ix i . ptPos) (+.+ vel)
$ set (particles . ix i . ptPict) pic
$ set (particles . ix i . ptUpdate)
Nothing -> over (projectiles . ix i . ptPos) (+.+ vel)
$ set (projectiles . ix i . ptPict) pic
$ set (projectiles . ix i . ptUpdate)
(moveRemoteShell (time-1) i cid itid newdir)
$ setScope
w
| otherwise = doExplosion
$ stopSoundFrom (ShellSound i)
w
where pt = _particles w IM.! i
where pt = _projectiles w IM.! i
oldPos = _ptPos pt
vel = _ptVel pt
newPos = oldPos +.+ vel
@@ -1557,23 +1557,23 @@ moveRemoteShell time i cid itid dir w
explodeRemoteRocket :: Int -> Int -> Int -> World -> World
explodeRemoteRocket itid ptid n w
= set (particles . ix ptid . ptUpdate) (retireRemoteRocket itid 30 ptid)
$ set (particles . ix ptid . ptPict) blank
= set (projectiles . ix ptid . ptUpdate) (retireRemoteRocket itid 30 ptid)
$ set (projectiles . ix ptid . ptPict) blank
$ set (itPoint . wpFire) (flip const)
$ resetName
-- $ resetScope
$ makeExplosionAt (_ptPos (_particles w IM.! ptid)) w
-- $ makeShrapnelBombAt (_ptPos (_particles w IM.! ptid)) w
$ makeExplosionAt (_ptPos (_projectiles w IM.! ptid)) w
-- $ makeShrapnelBombAt (_ptPos (_projectiles w IM.! ptid)) w
where resetName = set (itPoint . itName) "REMOTELAUNCHER"
-- resetScope = creatures . ix n . crInv . ix j . itScope . _Just . scopePos .~ (0,0)
itPoint = pointToItem $ _itemPositions w IM.! itid
throwRemoteBomb :: Int -> World -> World
throwRemoteBomb n w = setLocation $ removePict $ resetFire
-- $ resetName $ over particles addG $ set randGen g w
$ resetName $ over particles addG w
-- $ resetName $ over projectiles addG $ set randGen g w
$ resetName $ over projectiles addG w
where addG = IM.insert i
$ Particle { _ptPos = p
$ Projectile { _ptPos = p
, _ptStartPos = p
, _ptVel = v
, _ptPict = blank
@@ -1608,14 +1608,14 @@ throwRemoteBomb n w = setLocation $ removePict $ resetFire
explodeRemoteBomb :: Int -> Int -> Int -> World -> World
explodeRemoteBomb itid ptid n w
= set (particles . ix ptid . ptUpdate) (retireRemoteBomb itid 30 ptid)
$ set (particles . ix ptid . ptPict) blank
= set (projectiles . ix ptid . ptUpdate) (retireRemoteBomb itid 30 ptid)
$ set (projectiles . ix ptid . ptPict) blank
$ set (creatures . ix n . crInv . ix j . twFire) (flip const)
$ resetName
$ resetPict
-- $ resetScope
$ makeExplosionAt (_ptPos (_particles w IM.! ptid)) w
-- $ makeShrapnelBombAt (_ptPos (_particles w IM.! ptid)) w
$ makeExplosionAt (_ptPos (_projectiles w IM.! ptid)) w
-- $ makeShrapnelBombAt (_ptPos (_projectiles w IM.! ptid)) w
where resetName = set (creatures . ix n . crInv . ix j . itName) "REMOTEBOMB"
resetPict = set (creatures . ix n . crInv . ix j . itEquipPict )
(drawWeapon $ remoteBombUnarmedPic)
@@ -1635,8 +1635,8 @@ remoteBombUnarmedPic :: Picture
remoteBombUnarmedPic = color (dark $ dark orange) $ circleSolid 5
makeTeslaArcAt :: Int -> Point2 -> Float -> Particle
makeTeslaArcAt i pos dir = Particle
makeTeslaArcAt :: Int -> Point2 -> Float -> Projectile
makeTeslaArcAt i pos dir = Projectile
{ _ptPos = pos
, _ptStartPos = pos
, _ptVel = (0,0)
@@ -1647,8 +1647,8 @@ makeTeslaArcAt i pos dir = Particle
moveTeslaArc :: Point2 -> Float -> Int -> World -> World
moveTeslaArc p d i w =
set (particles . ix i . ptPict) pic
$ set (particles . ix i . ptUpdate)
set (projectiles . ix i . ptPict) pic
$ set (projectiles . ix i . ptUpdate)
(ptTimer 2 i)
$ set randGen g
$ createSpark 8 nc q2 (argV sv + d1) Nothing
@@ -1854,7 +1854,7 @@ forceFieldFire cid w = w
-- (_wpFireRate (_crInv cr IM.! itRef))
-- $ over (creatures . ix n . crInv . ix itRef . wpLoadedAmmo)
-- (\x -> x - 1)
-- $ over particles (IM.insert i $ makeTremorAt i pos dir) w
-- $ over projectiles (IM.insert i $ makeTremorAt i pos dir) w
-- | reloadCondition = let remAmmo = _crAmmo cr M.! _wpAmmoType item
-- (newA,newTotalA) = moveInt (_wpMaxAmmo item) remAmmo
-- in set (pointerToItem . wpReloadState) rTime
@@ -1888,12 +1888,12 @@ moveInt toReload totalAmmo = (x, totalAmmo-x)
updateTractor :: Int -> Int -> Int -> World -> World
updateTractor colID time i w
| time > 0 = set (particles . ix i . ptUpdate) (updateTractor colID (time-1) i)
$ set (particles . ix i . ptPict) pic
| time > 0 = set (projectiles . ix i . ptUpdate) (updateTractor colID (time-1) i)
$ set (projectiles . ix i . ptPict) pic
$ over creatures (IM.map tractCr)
$ over floorItems (IM.map tractFlIt)
w
| otherwise = over particles (IM.delete i) w
| otherwise = over projectiles (IM.delete i) w
where tractCr cr | circOnLine p1 p2 cP 10
= over crPos (\p ->
p -.- m *.* ((0.3/ x) *.* q +.+ (f y *.* p4))
@@ -1914,7 +1914,7 @@ updateTractor colID time i w
iP = _flItPos it
m | dist iP p1 < 350 = 1
| otherwise = (410 - dist iP p1) / 60
pt = _particles w IM.! i
pt = _projectiles w IM.! i
q = _ptVel pt
p1 = _ptPos pt
p' = _ptStartPos pt
+3 -4
View File
@@ -132,7 +132,7 @@ bulHitWall' bt p x w = damageBlocks x
pOut = p +.+ safeNormalizeV (sp -.- p)
(colID,g) = randomR (0,11) $ _randGen w
(a, _) = randomR (-0.1,0.1) $ _randGen w
spid = newKey $ _particles w
spid = newKey $ _projectiles w
reflectDir wall = a + (argV $ reflectIn
(_wlLine wall !! 1 -.- _wlLine wall !! 0)
(p -.- sp)
@@ -160,7 +160,7 @@ bulBounceWall' bt p wl w = damageBlocks wl
reflectVel = (reflectIn wallV (_btVel' bt))
addBouncer = (.) (over particles' ((:) bouncer))
-- the hack is to get around the fact that the particles' list gets reset after
-- all particles in it are checked, so we cannot add to it as we accumulate over
-- all projectiles in it are checked, so we cannot add to it as we accumulate over
-- this list
bulIncWall' :: Particle' -> Point2 -> Wall -> World -> World
@@ -181,7 +181,6 @@ bulIncWall' bt p wl w = damageBlocks wl
bulConWall' :: Particle' -> Point2 -> Wall -> World -> World
bulConWall' bt p wl w = damageBlocks wl
$ mkwave
-- yay for hack -- should have used this before? or never?
w
where sp = head $ _btTrail' bt
pOut = p +.+ safeNormalizeV (sp -.- p)
@@ -199,7 +198,7 @@ hvBulHitWall' bt p x w = damageBlocks x
where sp = head $ _btTrail' bt
pOut = p +.+ safeNormalizeV (sp -.- p)
(a, g) = randomR (-0.1,0.1) $ _randGen w
spid = newKey $ _particles w
spid = newKey $ _projectiles w
reflectDir wall = a + (argV $ reflectIn
(_wlLine wall !! 1 -.- _wlLine wall !! 0)
(p -.- sp)