Add check to cylinder segment collision, break rocket projectiles
This commit is contained in:
@@ -2,6 +2,11 @@
|
||||
--{-# OPTIONS_GHC -Wno-unused-imports #-}
|
||||
module Dodge.Projectile.Update (updateProjectile) where
|
||||
|
||||
import Linear
|
||||
import Dodge.Render.List
|
||||
import Dodge.Render.Label
|
||||
import ShortShow
|
||||
import Picture.Base
|
||||
import Control.Monad
|
||||
import Data.List (delete)
|
||||
import Data.Maybe
|
||||
@@ -18,8 +23,6 @@ import Dodge.WorldEvent.Sound
|
||||
import Geometry
|
||||
import qualified IntMapHelp as IM
|
||||
import LensHelp
|
||||
import Linear.Metric
|
||||
import Linear.V3
|
||||
import NewInt
|
||||
import RandomHelp
|
||||
|
||||
@@ -257,16 +260,28 @@ moveStuckGrenade cid poff d pj w
|
||||
w & cWorld . lWorld . projectiles . ix (pj ^. pjID) . pjType .~ Grenade GStick
|
||||
|
||||
moveProjectile :: Projectile -> World -> World
|
||||
moveProjectile pj w
|
||||
moveProjectile pj w = moveProjectile' pj w
|
||||
& cWorld . lWorld . flares <>~
|
||||
(setLayer DebugLayer
|
||||
$ color red $ line [p, (p +v)]
|
||||
)
|
||||
where
|
||||
p = pj^. pjPos . _xy
|
||||
v = pj^. pjVel . _xy
|
||||
|
||||
|
||||
moveProjectile' :: Projectile -> World -> World
|
||||
moveProjectile' pj w
|
||||
| Just GStuckWall{} <- pj ^? pjType . gnHitEffect = w
|
||||
| Just (GStuckCreature crid poff d) <- pj ^? pjType . gnHitEffect =
|
||||
moveStuckGrenade crid poff d pj w
|
||||
| (p, Just (n, OWall wl)) <- collide3 sp (sp + _pjVel pj) w =
|
||||
| (p, Just (n, OWall wl)) <- collide3 sp (sp + 2 *^ _pjVel pj) w =
|
||||
shellHitWall p n wl pj w
|
||||
| (p, Just (_, OFloor)) <- collide3 sp (sp + _pjVel pj) w =
|
||||
| (p, Just (_, OFloor)) <- collide3 sp (sp + 2*^ _pjVel pj) w =
|
||||
shellHitFloor p pj w
|
||||
| (p, Just (_, OCreature cr)) <- collide3 sp (sp + _pjVel pj) w =
|
||||
shellHitCreature p cr pj w
|
||||
& cWorld . lWorld . flares <>~ test p cr w sp (_pjVel pj)
|
||||
| (_, Just (_, OChasmWall)) <- collide3 sp (sp + _pjVel pj) w =
|
||||
-- no stick or bounce for now
|
||||
w & cWorld . lWorld . projectiles . ix (pj ^. pjID) . pjTimer .~ 0
|
||||
@@ -278,6 +293,30 @@ moveProjectile pj w
|
||||
where
|
||||
sp = _pjPos pj
|
||||
|
||||
test p cr w sp v =
|
||||
(setLayer FixedCoordLayer
|
||||
$ uncurryV translate (worldPosToScreen (w ^. wCam) (p ^. _xy))
|
||||
$ drawList [text (shortShow p),text $shortShow sp, text $ shortShow $ sp + 2*v, text $ shortShow v]
|
||||
<> color white (crossPic 5)
|
||||
) <>
|
||||
(setLayer DebugLayer
|
||||
$ uncurryV translate (p ^. _xy)
|
||||
$ ( scale 0.1 0.1
|
||||
$ stackPicturesAt
|
||||
[ text $ shortShow p
|
||||
, text $ shortShow sp
|
||||
, text $ shortShow (sp + v)
|
||||
]
|
||||
) <> color green (crossPic 5)
|
||||
) <>
|
||||
setLayer DebugLayer
|
||||
(uncurryV translate (cr ^. crPos . _xy)
|
||||
$ circle 10
|
||||
) <>
|
||||
(setLayer DebugLayer
|
||||
$ color red $ line [sp^. _xy, (sp +v)^._xy]
|
||||
)
|
||||
|
||||
explodeShell :: Projectile -> World -> World
|
||||
explodeShell pj w =
|
||||
w
|
||||
|
||||
Reference in New Issue
Block a user