Refactor projectiles
This commit is contained in:
@@ -14,7 +14,7 @@ import Dodge.Prop.Gib
|
||||
--import Dodge.Item.Weapon.Grenade
|
||||
import Dodge.Item.Equipment.Booster
|
||||
import Dodge.Item.Weapon.Utility
|
||||
import Dodge.Item.Weapon.Drone
|
||||
--import Dodge.Item.Weapon.Drone
|
||||
import Dodge.Item.Craftable
|
||||
import Dodge.Creature.LauncherCrit
|
||||
import Dodge.Creature.PistolCrit
|
||||
@@ -277,7 +277,7 @@ stackedInventory = IM.fromList $ zip [0..]
|
||||
,flameThrower
|
||||
,poisonSprayer
|
||||
,launcher
|
||||
,droneLauncher
|
||||
-- ,droneLauncher
|
||||
--,lasGun
|
||||
--,grenade
|
||||
--,ltAutoGun,flamer,multGun,spreadGun,remoteLauncher
|
||||
|
||||
+35
-32
@@ -159,6 +159,7 @@ data World = World
|
||||
, _gusts :: IM.IntMap Gust
|
||||
, _gsZoning :: Zoning IM.IntMap Gust
|
||||
, _props :: IM.IntMap Prop
|
||||
, _projectiles :: IM.IntMap Proj
|
||||
, _instantBullets :: [Bullet]
|
||||
, _bullets :: [Bullet]
|
||||
, _instantParticles :: [Particle]
|
||||
@@ -718,16 +719,40 @@ data Modification
|
||||
, _mdExternalID2 :: Int
|
||||
, _mdUpdate :: Modification -> World -> World
|
||||
}
|
||||
data Prop
|
||||
= Projectile
|
||||
{ _prPos :: Point2
|
||||
, _pjStartPos :: Point2
|
||||
, _pjVel :: Point2
|
||||
, _prDraw :: Prop -> SPic
|
||||
, _pjID :: Int
|
||||
, _pjUpdate :: Prop -> World -> World
|
||||
data Proj
|
||||
= RemoteShell
|
||||
{ _prjPos :: Point2
|
||||
, _prjStartPos :: Point2
|
||||
, _prjVel :: Point2
|
||||
, _prjDraw :: ProjectileDraw
|
||||
, _prjID :: Int
|
||||
, _prjUpdate :: Proj -> World -> World
|
||||
, _prjPayload :: Payload
|
||||
}
|
||||
| PropZ
|
||||
| Shell
|
||||
{ _prjPos :: Point2
|
||||
, _prjStartPos :: Point2
|
||||
, _prjVel :: Point2
|
||||
, _prjAcc :: Point2
|
||||
, _prjDir :: Float
|
||||
, _prjSpin :: Float
|
||||
, _prjDraw :: ProjectileDraw
|
||||
, _prjID :: Int
|
||||
, _prjUpdate :: Proj -> World -> World
|
||||
, _prjPayload :: Payload
|
||||
, _prjTimer :: Int
|
||||
, _prjZ :: Float
|
||||
}
|
||||
data Prop
|
||||
-- = Projectile
|
||||
-- { _prPos :: Point2
|
||||
-- , _pjStartPos :: Point2
|
||||
-- , _pjVel :: Point2
|
||||
-- , _prDraw :: Prop -> SPic
|
||||
-- , _pjID :: Int
|
||||
-- , _pjUpdate :: Prop -> World -> World
|
||||
-- }
|
||||
= PropZ
|
||||
{ _prPos :: Point2
|
||||
, _pjStartPos :: Point2
|
||||
, _pjVel :: Point2
|
||||
@@ -773,29 +798,6 @@ data Prop
|
||||
, _prDraw :: Prop -> SPic
|
||||
, _prToggle :: Bool
|
||||
}
|
||||
| RemoteShell
|
||||
{ _prPos :: Point2
|
||||
, _pjStartPos :: Point2
|
||||
, _pjVel :: Point2
|
||||
, _prDraw :: Prop -> SPic
|
||||
, _pjID :: Int
|
||||
, _pjUpdate :: Prop -> World -> World
|
||||
, _pjPayload :: Point2 -> World -> World
|
||||
}
|
||||
| Shell
|
||||
{ _prPos :: Point2
|
||||
, _pjStartPos :: Point2
|
||||
, _pjVel :: Point2
|
||||
, _pjAcc :: Point2
|
||||
, _pjDir :: Float
|
||||
, _pjSpin :: Float
|
||||
, _prDraw :: Prop -> SPic
|
||||
, _pjID :: Int
|
||||
, _pjUpdate :: Prop -> World -> World
|
||||
, _pjPayload :: Point2 -> World -> World
|
||||
, _pjTimer :: Int
|
||||
, _pjZ :: Float
|
||||
}
|
||||
| Bomb
|
||||
{ _prPos :: Point2
|
||||
, _pjVel :: Point2
|
||||
@@ -1307,6 +1309,7 @@ makeLenses ''ItemConsumption
|
||||
makeLenses ''AmmoType
|
||||
makeLenses ''TweakParam
|
||||
makeLenses ''Prop
|
||||
makeLenses ''Proj
|
||||
makeLenses ''Modification
|
||||
makeLenses ''Particle
|
||||
makeLenses ''PressPlate
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
--{-# LANGUAGE StrictData #-}
|
||||
module Dodge.Data.Ammo where
|
||||
|
||||
data ProjectileDraw = DrawShell | DrawRemoteShell
|
||||
data ProjectileDraw = DrawShell | DrawRemoteShell | DrawDrone | DrawBlankProjectile
|
||||
data ProjectileCreate = CreateShell
|
||||
data ProjectileUpdate = LaunchPJ | SpinPJ | ThrustPJ | FloatPJ
|
||||
|
||||
|
||||
@@ -2,13 +2,13 @@ module Dodge.Default.Prop where
|
||||
import Dodge.Data
|
||||
import Geometry
|
||||
defaultProp :: Prop
|
||||
defaultProp = Projectile
|
||||
defaultProp = ShapeProp
|
||||
{ _prPos = V2 0 0
|
||||
, _pjStartPos = V2 0 0
|
||||
, _pjVel = V2 0 0
|
||||
, _prDraw = const mempty
|
||||
, _pjID = 0
|
||||
, _pjUpdate = const id
|
||||
, _prToggle = True
|
||||
, _pjRot = 0
|
||||
}
|
||||
defaultShapeProp :: Prop
|
||||
defaultShapeProp = ShapeProp
|
||||
|
||||
+13
-14
@@ -1,21 +1,20 @@
|
||||
module Dodge.Default.Shell
|
||||
where
|
||||
import Dodge.Data
|
||||
import Picture
|
||||
import Geometry.Data
|
||||
|
||||
defaultShell :: Prop
|
||||
defaultShell :: Proj
|
||||
defaultShell = Shell
|
||||
{ _prPos = V2 0 0
|
||||
, _pjZ = 20
|
||||
, _pjStartPos = V2 0 0
|
||||
, _pjVel = V2 0 0
|
||||
, _pjAcc = V2 0 0
|
||||
, _pjDir = 0
|
||||
, _pjSpin = 0
|
||||
, _prDraw = const (mempty, blank)
|
||||
, _pjID = 0
|
||||
, _pjTimer = 0
|
||||
, _pjUpdate = const id
|
||||
, _pjPayload = const id
|
||||
{ _prjPos = V2 0 0
|
||||
, _prjZ = 20
|
||||
, _prjStartPos = V2 0 0
|
||||
, _prjVel = V2 0 0
|
||||
, _prjAcc = V2 0 0
|
||||
, _prjDir = 0
|
||||
, _prjSpin = 0
|
||||
, _prjDraw = DrawShell
|
||||
, _prjID = 0
|
||||
, _prjTimer = 0
|
||||
, _prjUpdate = const id
|
||||
, _prjPayload = ExplosionPayload
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ defaultWorld = World
|
||||
, _gsZoning = Zoning IM.empty clZoneSize (zonePos _guPos)
|
||||
, _itemPositions = IM.empty
|
||||
, _props = IM.empty
|
||||
, _projectiles = IM.empty
|
||||
, _instantBullets = []
|
||||
, _bullets = []
|
||||
, _instantParticles = []
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
module Dodge.Item.Weapon.Drone where
|
||||
import Dodge.Projectile.Draw
|
||||
--import Dodge.Projectile.Draw
|
||||
import Dodge.Data
|
||||
import Dodge.Default.Weapon
|
||||
--import Dodge.Default
|
||||
@@ -7,17 +7,10 @@ import Dodge.SoundLogic.LoadSound
|
||||
import Dodge.Item.Weapon.TriggerType
|
||||
import Geometry
|
||||
import Picture
|
||||
import qualified IntMapHelp as IM
|
||||
import ShapePicture
|
||||
import Shape
|
||||
|
||||
--import qualified Data.Set as S
|
||||
--import qualified SDL
|
||||
--import Data.Maybe
|
||||
import Control.Lens
|
||||
--import Control.Applicative
|
||||
--import Control.Monad.State
|
||||
--import System.Random
|
||||
|
||||
droneLauncher :: Item
|
||||
droneLauncher = defaultWeapon
|
||||
@@ -49,18 +42,19 @@ aDroneWithItemParams
|
||||
-> Creature
|
||||
-> World
|
||||
-> World
|
||||
aDroneWithItemParams it cr w = over props (IM.insert i theShell) w
|
||||
where
|
||||
am = _itConsumption it
|
||||
i = IM.newKey $ _props w
|
||||
pos = _crPos cr +.+ ((_crRad cr +1) *.* unitVectorAtAngle dir)
|
||||
dir = _crDir cr
|
||||
--ammoMvs pj w' = foldr (\pjP -> _pjMoveParam pjP (_pjIntParam pjP) it cr pj) w' (_amPjParams am)
|
||||
theShell = Drone
|
||||
{ _prPos = pos
|
||||
, _pjStartPos = pos
|
||||
, _pjVel = rotateV dir (V2 1 0)
|
||||
, _prDraw = drawProjectile (_amPjDraw $ _laAmmoType am)
|
||||
, _pjID = i
|
||||
, _pjUpdate = const id
|
||||
}
|
||||
aDroneWithItemParams = undefined
|
||||
--aDroneWithItemParams it cr w = over props (IM.insert i theShell) w
|
||||
-- where
|
||||
-- am = _itConsumption it
|
||||
-- i = IM.newKey $ _props w
|
||||
-- pos = _crPos cr +.+ ((_crRad cr +1) *.* unitVectorAtAngle dir)
|
||||
-- dir = _crDir cr
|
||||
-- --ammoMvs pj w' = foldr (\pjP -> _pjMoveParam pjP (_pjIntParam pjP) it cr pj) w' (_amPjParams am)
|
||||
-- theShell = Drone
|
||||
-- { _prPos = pos
|
||||
-- , _pjStartPos = pos
|
||||
-- , _pjVel = rotateV dir (V2 1 0)
|
||||
-- , _prDraw = undefined
|
||||
-- , _pjID = i
|
||||
-- , _pjUpdate = const id
|
||||
-- }
|
||||
|
||||
@@ -15,7 +15,6 @@ import ShapePicture
|
||||
import Shape
|
||||
import qualified IntMapHelp as IM
|
||||
|
||||
import Data.Maybe
|
||||
import Control.Lens
|
||||
|
||||
--grenade :: Item
|
||||
@@ -218,41 +217,43 @@ moveRemoteBomb itid time pID w
|
||||
|
||||
|
||||
throwRemoteBomb :: Creature -> World -> World
|
||||
throwRemoteBomb cr w = setLocation
|
||||
$ removePict
|
||||
$ resetFire
|
||||
-- $ resetName
|
||||
$ over props addG w
|
||||
where
|
||||
cid = _crID cr
|
||||
addG = IM.insert i $ Projectile
|
||||
{ _prPos = p
|
||||
, _pjStartPos = p
|
||||
, _pjVel = v
|
||||
, _prDraw = const mempty
|
||||
, _pjID = i
|
||||
, _pjUpdate = \_ -> moveRemoteBomb itid 50 i
|
||||
}
|
||||
i = IM.newKey $ _props w
|
||||
v' = 0.02 / _cameraZoom w *.* rotateV (_cameraRot w) ( _mousePos w)
|
||||
v | magV v' > 6 = 6 *.* normalizeV v'
|
||||
| otherwise = v'
|
||||
j = crSel cr
|
||||
-- resetName = set (creatures . ix cid . crInv . ix j . itName) "REMOTE"
|
||||
removePict = id -- set (creatures . ix cid . crInv . ix j . itEquipPict) $ \ _ _ -> mempty
|
||||
resetFire = set (creatures . ix cid . crInv . ix j . itUse . rUse)
|
||||
$ \_ -> explodeRemoteBomb itid i
|
||||
p' = _crPos cr +.+ rotateV (_crDir cr) (V2 (_crRad cr) 0)
|
||||
p | circOnSomeWall p' 4 w = _crPos cr +.+ rotateV (_crDir cr) (V2 (_crRad cr-4) 0)
|
||||
| otherwise = p'
|
||||
maybeitid = w ^? creatures . ix cid . crInv . ix j . itID . _Just
|
||||
setLocation :: World -> World
|
||||
setLocation w' = case maybeitid of
|
||||
Nothing -> w' & creatures . ix cid . crInv . ix j . itID ?~ newitid
|
||||
& itemPositions %~ IM.insert newitid (InInv cid j)
|
||||
_ -> w'
|
||||
newitid = IM.newKey $ _itemPositions w
|
||||
itid = fromMaybe newitid maybeitid
|
||||
throwRemoteBomb = undefined
|
||||
--throwRemoteBomb cr w = undefined
|
||||
-- setLocation
|
||||
-- $ removePict
|
||||
-- $ resetFire
|
||||
---- $ resetName
|
||||
-- $ over props addG w
|
||||
-- where
|
||||
-- cid = _crID cr
|
||||
-- addG = IM.insert i $ Projectile
|
||||
-- { _prPos = p
|
||||
-- , _pjStartPos = p
|
||||
-- , _pjVel = v
|
||||
-- , _prDraw = const mempty
|
||||
-- , _pjID = i
|
||||
-- , _pjUpdate = \_ -> moveRemoteBomb itid 50 i
|
||||
-- }
|
||||
-- i = IM.newKey $ _props w
|
||||
-- v' = 0.02 / _cameraZoom w *.* rotateV (_cameraRot w) ( _mousePos w)
|
||||
-- v | magV v' > 6 = 6 *.* normalizeV v'
|
||||
-- | otherwise = v'
|
||||
-- j = crSel cr
|
||||
---- resetName = set (creatures . ix cid . crInv . ix j . itName) "REMOTE"
|
||||
-- removePict = id -- set (creatures . ix cid . crInv . ix j . itEquipPict) $ \ _ _ -> mempty
|
||||
-- resetFire = set (creatures . ix cid . crInv . ix j . itUse . rUse)
|
||||
-- $ \_ -> explodeRemoteBomb itid i
|
||||
-- p' = _crPos cr +.+ rotateV (_crDir cr) (V2 (_crRad cr) 0)
|
||||
-- p | circOnSomeWall p' 4 w = _crPos cr +.+ rotateV (_crDir cr) (V2 (_crRad cr-4) 0)
|
||||
-- | otherwise = p'
|
||||
-- maybeitid = w ^? creatures . ix cid . crInv . ix j . itID . _Just
|
||||
-- setLocation :: World -> World
|
||||
-- setLocation w' = case maybeitid of
|
||||
-- Nothing -> w' & creatures . ix cid . crInv . ix j . itID ?~ newitid
|
||||
-- & itemPositions %~ IM.insert newitid (InInv cid j)
|
||||
-- _ -> w'
|
||||
-- newitid = IM.newKey $ _itemPositions w
|
||||
-- itid = fromMaybe newitid maybeitid
|
||||
|
||||
explodeRemoteBomb :: Int -> Int -> Creature -> World -> World
|
||||
explodeRemoteBomb itid pjid cr w
|
||||
|
||||
@@ -6,7 +6,6 @@ module Dodge.Item.Weapon.Launcher
|
||||
) where
|
||||
import Dodge.Data
|
||||
import Dodge.Payload
|
||||
import Dodge.Projectile.Draw
|
||||
import Dodge.Reloading.Action
|
||||
import Dodge.EnergyBall
|
||||
import Dodge.Default.Weapon
|
||||
@@ -128,14 +127,14 @@ thrustParam = TweakParam
|
||||
, _nameTweak = "THRUST DELAY"
|
||||
}
|
||||
|
||||
pjThrust :: Int -> Prop -> World -> World
|
||||
pjThrust :: Int -> Proj -> World -> World
|
||||
pjThrust i = pjEffTimeRange (st,et) doThrust
|
||||
where
|
||||
et | i == 0 = 36
|
||||
| otherwise = 40 - (i * 20)
|
||||
st = et - 100
|
||||
|
||||
pjTrack :: Int -> Int -> Prop -> World -> World
|
||||
pjTrack :: Int -> Int -> Proj -> World -> World
|
||||
pjTrack itid i pj w = pjEffTimeRange (st,et) rotateToTarget pj w
|
||||
where
|
||||
et | i == 0 = 36
|
||||
@@ -143,22 +142,23 @@ pjTrack itid i pj w = pjEffTimeRange (st,et) rotateToTarget pj w
|
||||
st = et - 100
|
||||
rotateToTarget _ = fromMaybe id $ do
|
||||
tpos <- w ^? itPoint . itTargeting . tgPos . _Just
|
||||
return $ props . ix (_pjID pj) . pjSpin .~ turnToAmount 0.15 (_prPos pj) tpos (argV $ _pjAcc pj)
|
||||
return $ projectiles . ix (_prjID pj) . prjSpin .~ turnToAmount 0.15 (_prjPos pj) tpos
|
||||
(argV $ _prjAcc pj)
|
||||
itPoint = pointToItem $ _itemPositions w IM.! itid
|
||||
|
||||
doThrust :: Prop -> World -> World
|
||||
doThrust :: Proj -> World -> World
|
||||
doThrust pj w = w
|
||||
& randGen .~ g
|
||||
& props . ix i . pjVel %~ (\v -> accel +.+ frict *.* v)
|
||||
& projectiles . ix i . prjVel %~ (\v -> accel +.+ frict *.* v)
|
||||
& soundContinue (ShellSound i) newPos missileLaunchS (Just 1)
|
||||
& makeFlamelet (oldPos -.- vel) 0 (vel +.+ rotateV (pi+sparkD) accel) 3 10
|
||||
& shellTrailCloud (addZ 20 (oldPos +.+ r1 +.+ 30 *.* normalizeV (oldPos -.- newPos)))
|
||||
where
|
||||
accel = _pjAcc pj
|
||||
i = _pjID pj
|
||||
oldPos = _prPos pj
|
||||
vel = _pjVel pj
|
||||
newPos = oldPos +.+ vel
|
||||
accel = _prjAcc pj
|
||||
i = _prjID pj
|
||||
oldPos = _prjPos pj
|
||||
vel = _prjVel pj
|
||||
newPos = oldPos +.+ vel
|
||||
(frict,g) = randomR (0.6,0.9) $ _randGen w
|
||||
(sparkD,_) = randomR (-0.2,0.2) $ _randGen w
|
||||
r1 = randInCirc 10 & evalState $ _randGen w
|
||||
@@ -175,7 +175,7 @@ fireShell it cr = makeShell it cr $ \pj -> pjEffAtTime 35 (trySpinByCID (_crID c
|
||||
spinamount = _shellSpinAmount params
|
||||
thrustdelay = _shellThrustDelay params
|
||||
|
||||
moveShell :: Prop -- ^ Projectile id
|
||||
moveShell :: Proj -- ^ Projectile id
|
||||
-> World
|
||||
-> World
|
||||
moveShell pj w
|
||||
@@ -186,56 +186,51 @@ moveShell pj w
|
||||
| time > -300 = w
|
||||
| otherwise = doExplode
|
||||
where
|
||||
time = _pjTimer pj
|
||||
time = _prjTimer pj
|
||||
doExplode = w
|
||||
& _pjPayload pj oldPos
|
||||
& usePayload (_prjPayload pj) oldPos
|
||||
& stopSoundFrom (ShellSound i)
|
||||
& props %~ IM.delete i
|
||||
i = _pjID pj
|
||||
oldPos = _prPos pj
|
||||
vel = _pjVel pj
|
||||
& projectiles %~ IM.delete i
|
||||
i = _prjID pj
|
||||
oldPos = _prjPos pj
|
||||
vel = _prjVel pj
|
||||
newPos = oldPos +.+ vel
|
||||
|
||||
reduceSpinBy :: Float -> Prop -> World -> World
|
||||
reduceSpinBy x pj = props . ix (_pjID pj) . pjSpin *~ x
|
||||
|
||||
|
||||
--shellShape :: Shape
|
||||
--shellShape = colorSH black $ upperPrismPoly 4 $ map toV2 [(-6,4),(-6,-4),(6,-4),(8,0),(6,4)]
|
||||
|
||||
reduceSpinBy :: Float -> Proj -> World -> World
|
||||
reduceSpinBy x pj = projectiles . ix (_prjID pj) . prjSpin *~ x
|
||||
|
||||
pjEffTimeRange
|
||||
:: (Int,Int)
|
||||
-> (Prop -> World -> World)
|
||||
-> Prop
|
||||
-> (Proj -> World -> World)
|
||||
-> Proj
|
||||
-> World
|
||||
-> World
|
||||
pjEffTimeRange (st,et) f pj
|
||||
| t <= et && t >= st = f pj
|
||||
| otherwise = id
|
||||
where
|
||||
t = _pjTimer pj
|
||||
t = _prjTimer pj
|
||||
|
||||
pjEffAtTime
|
||||
:: Int
|
||||
-> (Prop -> World -> World)
|
||||
-> Prop
|
||||
-> (Proj -> World -> World)
|
||||
-> Proj
|
||||
-> World
|
||||
-> World
|
||||
pjEffAtTime t f pj
|
||||
| _pjTimer pj == t = f pj
|
||||
| _prjTimer pj == t = f pj
|
||||
| otherwise = id
|
||||
|
||||
trySpinByCID
|
||||
:: Int -- ^ creature id
|
||||
-> Int -- ^ Spin amount
|
||||
-> Prop
|
||||
-> Proj
|
||||
-> World
|
||||
-> World
|
||||
trySpinByCID cid i pj w = w & props . ix pjid . pjSpin .~ newSpin
|
||||
trySpinByCID cid i pj w = w & projectiles . ix pjid . prjSpin .~ newSpin
|
||||
where
|
||||
pjid = _pjID pj
|
||||
dir = argV $ _pjVel pj
|
||||
pjid = _prjID pj
|
||||
dir = argV $ _prjVel pj
|
||||
newSpin = case w ^? creatures . ix cid of
|
||||
Just cr -> negate $ min 0.2 $ max (-0.2) $ normalizeAnglePi (dir - _crDir cr) / spinFactor
|
||||
_ -> 0
|
||||
@@ -252,27 +247,26 @@ remoteLauncher = launcher
|
||||
fireRemoteShell :: Item -> Creature -> World -> World
|
||||
fireRemoteShell it cr w = set (creatures . ix cid . crInv . ix j . itUse . rUse)
|
||||
(\_ _ -> explodeRemoteRocket itid i)
|
||||
-- $ set (creatures . ix cid . crInv . ix j . itName) remoteLauncherName
|
||||
$ addRemRocket w'
|
||||
where
|
||||
(w',itid) = getHeldItemLoc cr w
|
||||
i = IM.newKey $ _props w
|
||||
cid = _crID cr
|
||||
addRemRocket = makeShell it cr $ \pj ->
|
||||
decTimMvVel pj . setRemoteScope itid pj . moveRemoteShell cid itid pj
|
||||
decTimMvVel pj . setRemoteScope itid (_prjPos pj) . moveRemoteShell cid itid pj
|
||||
j = crSel cr
|
||||
|
||||
moveRemoteShell :: Int -> Int -> Prop -> World -> World
|
||||
moveRemoteShell :: Int -> Int -> Proj -> World -> World
|
||||
moveRemoteShell cid itid pj w
|
||||
| time > 40 = if circOnSomeWall oldPos 4 w
|
||||
then doExplosion
|
||||
else w
|
||||
| anythingHitCirc 2 oldPos newPos w = doExplosion
|
||||
| time >= 20 = w & props . ix i . pjDir .~ newdir
|
||||
| time >= 20 = w & projectiles . ix i . prjDir .~ newdir
|
||||
| time > -99 = w & set randGen g
|
||||
& props . ix i %~
|
||||
( ( pjVel %~ ( (accel +.+) . (frict *.*) ) )
|
||||
. ( pjDir .~ newdir )
|
||||
& projectiles . ix i %~
|
||||
( ( prjVel %~ ( (accel +.+) . (frict *.*) ) )
|
||||
. ( prjDir .~ newdir )
|
||||
)
|
||||
& soundContinue (ShellSound i) newPos missileLaunchS (Just 1)
|
||||
& smokeGen
|
||||
@@ -280,16 +274,16 @@ moveRemoteShell cid itid pj w
|
||||
| time > -200 = w
|
||||
| otherwise = doExplosion
|
||||
where
|
||||
time = _pjTimer pj
|
||||
i = _pjID pj
|
||||
oldPos = _prPos pj
|
||||
vel = _pjVel pj
|
||||
newPos = oldPos +.+ vel
|
||||
time = _prjTimer pj
|
||||
i = _prjID pj
|
||||
oldPos = _prjPos pj
|
||||
vel = _prjVel pj
|
||||
newPos = oldPos +.+ vel
|
||||
newdir
|
||||
| SDL.ButtonRight `M.member` _mouseButtons w
|
||||
&& w ^? creatures . ix cid . crInvSel . iselPos == w ^? itemPositions . ix itid . ipInvID
|
||||
= _cameraRot w + argV (_mousePos w)
|
||||
| otherwise = _pjDir pj
|
||||
| otherwise = _prjDir pj
|
||||
accel = rotateV newdir (V2 2 0)
|
||||
(frict,g) = randomR (0.6,0.9) $ _randGen w
|
||||
(sparkD,_) = randomR (-0.5,0.5) $ _randGen w
|
||||
@@ -303,21 +297,20 @@ anythingHitCirc rad sp ep w = hitCr || isJust (sequence hitWl)
|
||||
hitCr = runIdentity $ S.any_ (const True) $ overlap1SegCrs sp ep $ crsNearSeg sp ep w
|
||||
hitWl = collideCircWallsStream sp ep rad $ wlsNearPoint ep w
|
||||
-- this should probably be wallsOnLine or something
|
||||
|
||||
explodeRemoteRocket
|
||||
:: Int -- ^ Item id
|
||||
-> Int -- ^ Projectile id
|
||||
-> World
|
||||
-> World
|
||||
explodeRemoteRocket itid pjid w = w
|
||||
& props . ix pjid . pjUpdate .~ (\_ -> retireRemoteProj fireRemoteShell itid 30 pjid)
|
||||
& props . ix pjid . prDraw .~ const mempty
|
||||
& projectiles . ix pjid . prjUpdate .~ (\_ -> retireRemoteProj fireRemoteShell itid 30 pjid)
|
||||
& projectiles . ix pjid . prjDraw .~ DrawBlankProjectile
|
||||
& itPoint . itUse . rUse .~ (\_ _ -> id)
|
||||
-- & itPoint . itName .~ "REMOTELAUNCHER"
|
||||
& _pjPayload thepj (_prPos thepj)
|
||||
& usePayload (_prjPayload thepj) (_prjPos thepj)
|
||||
where
|
||||
itPoint = pointToItem $ _itemPositions w IM.! itid
|
||||
thepj = _props w IM.! pjid
|
||||
thepj = _projectiles w IM.! pjid
|
||||
|
||||
fireTrackingShell :: Item -> Creature -> World -> World
|
||||
fireTrackingShell it cr w = addTrackRocket w'
|
||||
@@ -334,20 +327,20 @@ fireTrackingShell it cr w = addTrackRocket w'
|
||||
spindrag = _shellSpinDrag params
|
||||
params = _itParams it
|
||||
|
||||
makeShell :: Item -> Creature -> (Prop -> World -> World) -> World -> World
|
||||
makeShell it cr theupdate w = w & props %~ IM.insert i Shell
|
||||
{ _prPos = pos
|
||||
, _pjZ = 20
|
||||
, _pjStartPos = pos
|
||||
, _pjVel = rotateV dir (V2 1 0)
|
||||
, _prDraw = drawProjectile (_amPjDraw $ _laAmmoType am)
|
||||
, _pjID = i
|
||||
, _pjUpdate = theupdate
|
||||
, _pjAcc = rotateV dir (V2 3 0)
|
||||
, _pjDir = dir
|
||||
, _pjSpin = 0
|
||||
, _pjPayload = usePayload $ _amPayload $ _laAmmoType am
|
||||
, _pjTimer = 50
|
||||
makeShell :: Item -> Creature -> (Proj -> World -> World) -> World -> World
|
||||
makeShell it cr theupdate w = w & projectiles %~ IM.insert i Shell
|
||||
{ _prjPos = pos
|
||||
, _prjZ = 20
|
||||
, _prjStartPos = pos
|
||||
, _prjVel = rotateV dir (V2 1 0)
|
||||
, _prjDraw = DrawShell
|
||||
, _prjID = i
|
||||
, _prjUpdate = theupdate
|
||||
, _prjAcc = rotateV dir (V2 3 0)
|
||||
, _prjDir = dir
|
||||
, _prjSpin = 0
|
||||
, _prjPayload = _amPayload $ _laAmmoType am
|
||||
, _prjTimer = 50
|
||||
}
|
||||
where
|
||||
i = IM.newKey $ _props w
|
||||
|
||||
@@ -40,9 +40,9 @@ setRemoteBombScope itid pj w' = case _itemPositions w' IM.! itid of
|
||||
.~ (defaultItZoom {_itZoomMax = 0.5, _itZoomMin = 0.5})
|
||||
_ -> w'
|
||||
|
||||
setRemoteScope :: Int -> Prop -> World -> World
|
||||
setRemoteScope itid pj w' = case w' ^? itemPositions . ix itid of
|
||||
setRemoteScope :: Int -> Point2 -> World -> World
|
||||
setRemoteScope itid pos w' = case w' ^? itemPositions . ix itid of
|
||||
Just (InInv cid' invid )
|
||||
-> w' & creatures . ix cid' . crInv . ix invid . itScope
|
||||
. scopePos .~ (_prPos pj -.- _crPos (_creatures w' IM.! cid'))
|
||||
. scopePos .~ (pos -.- _crPos (_creatures w' IM.! cid'))
|
||||
_ -> w'
|
||||
|
||||
@@ -5,13 +5,13 @@ import Dodge.Data
|
||||
import Geometry.Vector
|
||||
|
||||
import Control.Lens
|
||||
decTimMvVel :: Prop -> World -> World
|
||||
decTimMvVel pj = props . ix pjid %~
|
||||
( (pjTimer -~ 1)
|
||||
. (prPos %~ (+.+ vel) )
|
||||
. (pjAcc %~ rotateV rot )
|
||||
decTimMvVel :: Proj -> World -> World
|
||||
decTimMvVel pj = projectiles . ix pjid %~
|
||||
( (prjTimer -~ 1)
|
||||
. (prjPos %~ (+.+ vel) )
|
||||
. (prjAcc %~ rotateV rot )
|
||||
)
|
||||
where
|
||||
rot = _pjSpin pj
|
||||
vel = _pjVel pj
|
||||
pjid = _pjID pj
|
||||
rot = _prjSpin pj
|
||||
vel = _prjVel pj
|
||||
pjid = _prjID pj
|
||||
|
||||
@@ -5,19 +5,20 @@ import Picture
|
||||
import Shape
|
||||
import ShapePicture
|
||||
|
||||
drawProjectile :: ProjectileDraw -> Prop -> SPic
|
||||
drawProjectile pd = case pd of
|
||||
DrawShell -> drawShell
|
||||
DrawRemoteShell -> drawRemoteShell
|
||||
|
||||
drawShell :: Prop -> SPic
|
||||
drawProjectile :: Proj -> SPic
|
||||
drawProjectile prj = case _prjDraw prj of
|
||||
DrawShell -> drawShell prj
|
||||
DrawRemoteShell -> drawRemoteShell prj
|
||||
DrawDrone -> drawShell prj
|
||||
DrawBlankProjectile -> mempty
|
||||
drawShell :: Proj -> SPic
|
||||
drawShell pj = noPic
|
||||
. translateSHz 18
|
||||
. uncurryV translateSHf (_prPos pj)
|
||||
$ rotateSH (argV $ _pjAcc pj) shellShape
|
||||
. uncurryV translateSHf (_prjPos pj)
|
||||
$ rotateSH (argV $ _prjAcc pj) shellShape
|
||||
shellShape :: Shape
|
||||
shellShape = colorSH black $ upperPrismPoly 4 $ map toV2 [(-6,4),(-6,-4),(6,-4),(8,0),(6,4)]
|
||||
drawRemoteShell :: Prop -> SPic
|
||||
drawRemoteShell :: Proj -> SPic
|
||||
drawRemoteShell pj
|
||||
| rem (t+200) 20 < 9
|
||||
= doposition $ noPic shellShape
|
||||
@@ -25,8 +26,8 @@ drawRemoteShell pj
|
||||
where
|
||||
col | t > (-99) = green
|
||||
| otherwise = red
|
||||
t = _pjTimer pj
|
||||
doposition = translateSPz 18 . uncurryV translateSPf (_prPos pj) . rotateSP (_pjDir pj)
|
||||
t = _prjTimer pj
|
||||
doposition = translateSPz 18 . uncurryV translateSPf (_prjPos pj) . rotateSP (_prjDir pj)
|
||||
remoteShellShape :: Color -> SPic
|
||||
remoteShellShape col = (shellShape
|
||||
, setLayer BloomNoZWrite . setDepth 4.5 . color col $ circleSolid 3
|
||||
|
||||
@@ -2,6 +2,7 @@ module Dodge.Render.ShapePicture
|
||||
( worldSPic
|
||||
) where
|
||||
import Dodge.RadarSweep.Draw
|
||||
import Dodge.Projectile.Draw
|
||||
import Dodge.Item.Draw.SPic
|
||||
import Dodge.EnergyBall.Draw
|
||||
import Dodge.Creature.Picture.Awareness
|
||||
@@ -53,6 +54,7 @@ worldSPic :: Configuration -> World -> SPic
|
||||
worldSPic cfig w
|
||||
= singleSPic (mempty, extraPics cfig w)
|
||||
<> foldup (dbArg _prDraw) (filtOn _prPos _props)
|
||||
<> foldup drawProjectile (filtOn _prjPos _projectiles)
|
||||
<> foldup (shiftDraw _blPos _blDir _blDraw) (filtOn _blPos _blocks)
|
||||
<> foldup (shiftDraw _fsPos _fsDir (const _fsSPic)) (filtOn _fsPos _foregroundShapes)
|
||||
<> foldup (dbArg _cpPict) (filtOn _cpPos _corpses)
|
||||
|
||||
@@ -87,6 +87,7 @@ functionalUpdate cfig w = checkEndGame
|
||||
. updateFlares
|
||||
. updateBeams
|
||||
. updateIMl _props _pjUpdate
|
||||
. updateIMl _projectiles _prjUpdate
|
||||
. updateLightSources
|
||||
. updateClouds
|
||||
. updateGusts
|
||||
|
||||
Reference in New Issue
Block a user