Add boss room, tweak launchers

This commit is contained in:
2021-04-24 22:39:45 +02:00
parent 24ea24cd6d
commit 94ff3d6593
7 changed files with 347 additions and 64 deletions
+24 -61
View File
@@ -334,17 +334,17 @@ launcher = defaultGun
}
flameLauncher = launcher
{ _itName = "FLROCKO"
, _wpFire = shoot $ aRocket' makeFlameShellAt
, _wpFire = shoot . aRocket' $ makeShellAt makeFlameExplosionAt
}
poisonLauncher = launcher
{ _itName = "POISROCK"
, _wpFire = shoot $ aRocket' makePoisonShellAt
, _wpFire = shoot . aRocket' $ makeShellAt makePoisonExplosionAt
}
teslaLauncher = launcher
{ _itName = "TESLROCK"
, _wpFire = shoot $ aRocket' makeTeslaShellAt
, _wpFire = shoot . aRocket' $ makeShellAt makeTeslaExplosionAt
}
bezierGun = defaultAutoGun
@@ -712,7 +712,7 @@ aTractorBeam col cid w
dir = _crDir cr
itRef = _crInvSel cr
-- |The aRocket' function allows us to define the shell to be used
-- | The aRocket' function allows us to define the shell to be used
aRocket' :: (Int -> Int -> Point2 -> Float -> Projectile) -> Int -> World -> World
aRocket' shell cid w
= soundOnce (fromIntegral launcherSound)
@@ -723,70 +723,36 @@ aRocket' shell cid w
dir = _crDir cr
aRocket :: Int -> World -> World
aRocket = aRocket' makeShellAt
-- = soundOnce (fromIntegral launcherSound)
-- $ over projectiles (IM.insert i (makeShellAt i cid pos dir)) w
-- where i = newProjectileKey w
-- cr = (_creatures w IM.! cid)
-- pos = _crPos cr +.+ ((_crRad cr +1) *.* unitVectorAtAngle dir)
-- dir = _crDir cr
aRocket = aRocket' (makeShellAt shellExplosionAt)
makeShellAt :: Int -> Int -> Point2 -> Float -> Projectile
makeShellAt i cid pos dir = Shell
makeShellAt
:: (Point2 -> World -> World) -- ^ Payload
-> Int -- ^ Projectile id
-> Int -- ^ Creature id
-> Point2 -- ^ Start position
-> Float -- ^ Direction
-> Projectile
makeShellAt pl i cid pos dir = Shell
{ _pjPos = pos
, _pjStartPos = pos
, _pjVel = rotateV dir (1,0)
, _pjPict = blank -- onLayer PtLayer $ uncurry translate pos $ rotate (radToDeg dir) shellPic
, _pjID = i
, _pjUpdate = moveShell 50 i cid 0 (rotateV dir (2,0))
, _pjPayload = shellExplosionAt
}
makeFlameShellAt :: Int -> Int -> Point2 -> Float -> Projectile
makeFlameShellAt i cid pos dir = Shell
{ _pjPos = pos
, _pjStartPos = pos
, _pjVel = rotateV dir (1,0)
, _pjPict = blank -- onLayer PtLayer $ uncurry translate pos $ rotate (radToDeg dir) shellPic
, _pjID = i
, _pjUpdate = moveShell 50 i cid 0 (rotateV dir (2,0))
, _pjPayload = makeFlameExplosionAt
}
makePoisonShellAt :: Int -> Int -> Point2 -> Float -> Projectile
makePoisonShellAt i cid pos dir = Shell
{ _pjPos = pos
, _pjStartPos = pos
, _pjVel = rotateV dir (1,0)
, _pjPict = blank -- onLayer PtLayer $ uncurry translate pos $ rotate (radToDeg dir) shellPic
, _pjID = i
, _pjUpdate = moveShell 50 i cid 0 (rotateV dir (2,0))
, _pjPayload = makePoisonExplosionAt
}
makeTeslaShellAt :: Int -> Int -> Point2 -> Float -> Projectile
makeTeslaShellAt i cid pos dir = Shell
{ _pjPos = pos
, _pjStartPos = pos
, _pjVel = rotateV dir (1,0)
, _pjPict = blank -- onLayer PtLayer $ uncurry translate pos $ rotate (radToDeg dir) shellPic
, _pjID = i
, _pjUpdate = moveShell 50 i cid 0 (rotateV dir (2,0))
, _pjPayload = makeTeslaExplosionAt
, _pjUpdate = moveShell 50 i cid 0 (rotateV dir (3,0))
, _pjPayload = pl
}
moveShell :: Int -> Int -> Int -> Float -> Point2 -> World -> World
moveShell time i cid rot accel w
| time > 40 = if circOnSomeWall oldPos 4 w
then projectileExplosion oldPos $ over projectiles (IM.delete i) w
then doExplode
else over (projectiles . ix i . pjPos) (+.+ vel)
$ set (projectiles . ix i . pjPict) piclow
$ set (projectiles . ix i . pjUpdate)
(moveShell (time-1) i cid rot (rotateV rot accel))
w
| time == 35 = case thingHit of
Just p -> projectileExplosion oldPos
$ over projectiles (IM.delete i) w
Just p -> doExplode
Nothing -> over (projectiles . ix i . pjPos) (+.+ vel)
$ set (projectiles . ix i . pjPict) pic
$ set (projectiles . ix i . pjUpdate)
@@ -801,9 +767,7 @@ moveShell time i cid rot accel w
(moveShell (time-1) i cid rot (rotateV rot accel))
w
| time > -99 = case thingHit of
Just p -> projectileExplosion oldPos
$ stopSoundFrom (ShellSound i)
$ over projectiles (IM.delete i) w
Just p -> doExplode
Nothing -> over (projectiles . ix i . pjPos) (+.+ vel)
$ set randGen g
$ set (projectiles . ix i . pjPict) pic
@@ -816,18 +780,17 @@ moveShell time i cid rot accel w
$ smokeGen
w
| time > -200 = case thingHit of
Just p -> projectileExplosion oldPos
$ stopSoundFrom (ShellSound i)
$ over projectiles (IM.delete i) w
Just p -> doExplode
Nothing -> over (projectiles . ix i . pjPos) (+.+ vel)
$ set (projectiles . ix i . pjPict) pic
$ set (projectiles . ix i . pjUpdate)
(moveShell (time-1) i cid rot (rotateV rot accel))
w
| otherwise = projectileExplosion oldPos
$ stopSoundFrom (ShellSound i)
$ over projectiles (IM.delete i) w
| otherwise = doExplode
where
doExplode = projectileExplosion oldPos
$ stopSoundFrom (ShellSound i)
$ over projectiles (IM.delete i) w
pj = _projectiles w IM.! i
oldPos = _pjPos pj
vel = _pjVel pj
@@ -843,7 +806,7 @@ moveShell time i cid rot accel w
hitWl = fmap fst $ collideCircWalls' oldPos newPos 2 $ wallsNearPoint newPos w
thingHit = hitCr <|> hitWl
spin = case w ^? creatures . ix cid of
Just cr -> min 0.1 $ max (-0.1)
Just cr -> min 0.2 $ max (-0.2)
$ (normalizeAnglePi (dir - _crDir cr)) / 20
_ -> 0
r1 = _randGen w & evalState (randInCirc 10)