Work on radar and sonar
This commit is contained in:
@@ -734,6 +734,7 @@ data GunBarrels
|
|||||||
data EquipParams
|
data EquipParams
|
||||||
= NoEquipParams
|
= NoEquipParams
|
||||||
| EquipID {_eparamID :: Int}
|
| EquipID {_eparamID :: Int}
|
||||||
|
| EquipCounter {_eparamInt :: Int}
|
||||||
data ItemParams
|
data ItemParams
|
||||||
= NoParams
|
= NoParams
|
||||||
| ShellLauncher
|
| ShellLauncher
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ module Dodge.Item.Weapon.ExtraEffect
|
|||||||
) where
|
) where
|
||||||
import Dodge.Data
|
import Dodge.Data
|
||||||
import Dodge.Base
|
import Dodge.Base
|
||||||
|
import Dodge.SoundLogic
|
||||||
--import Dodge.Item.Weapon.Decoration
|
--import Dodge.Item.Weapon.Decoration
|
||||||
import Dodge.Item.Weapon.UseEffect
|
import Dodge.Item.Weapon.UseEffect
|
||||||
import Dodge.Item.Weapon.LaserPath
|
import Dodge.Item.Weapon.LaserPath
|
||||||
@@ -32,28 +33,25 @@ import Data.Maybe
|
|||||||
import qualified Data.Set as S
|
import qualified Data.Set as S
|
||||||
import qualified SDL
|
import qualified SDL
|
||||||
{- | Automatically send out radar pulses that detect walls. -}
|
{- | Automatically send out radar pulses that detect walls. -}
|
||||||
autoRadarEffect :: ItEffect
|
autoRadarEffect :: Item -> Creature -> World -> World
|
||||||
autoRadarEffect = ItInvEffect {_itInvEffect = f 50 ,_itEffectCounter = 0 }
|
autoRadarEffect itm cr w
|
||||||
where
|
| _eparamInt (_eqParams (_itUse itm)) < 1 = aRadarPulse cr w
|
||||||
f :: Int -> Item -> Creature -> World -> World
|
|
||||||
f 0 itm cr w = aRadarPulse cr w
|
|
||||||
& creatures . ix (_crID cr) . crInv . ix (fromJust $ _itInvPos itm)
|
& creatures . ix (_crID cr) . crInv . ix (fromJust $ _itInvPos itm)
|
||||||
. itEffect . itInvEffect .~ f 100
|
. itUse . eqParams . eparamInt .~ 100
|
||||||
f t itm cr w = w
|
& soundStart OnceSound (_crPos cr) click1S Nothing
|
||||||
|
| otherwise = w
|
||||||
& creatures . ix (_crID cr) . crInv . ix (fromJust $ _itInvPos itm)
|
& creatures . ix (_crID cr) . crInv . ix (fromJust $ _itInvPos itm)
|
||||||
. itEffect . itInvEffect .~ f (t-1)
|
. itUse . eqParams . eparamInt -~ 1
|
||||||
{- | Automatically send out sonar pulses that detect creatures. -}
|
{- | Automatically send out sonar pulses that detect creatures. -}
|
||||||
autoSonarEffect :: ItEffect
|
autoSonarEffect :: Item -> Creature -> World -> World
|
||||||
autoSonarEffect = ItInvEffect {_itInvEffect = f ,_itEffectCounter = 50 }
|
autoSonarEffect itm cr w
|
||||||
where
|
| _eparamInt (_eqParams (_itUse itm)) < 1 = aSonarPulse cr w
|
||||||
f :: Item -> Creature -> World -> World
|
& creatures . ix (_crID cr) . crInv . ix (fromJust $ _itInvPos itm)
|
||||||
f itm cr w
|
. itUse . eqParams . eparamInt .~ 50
|
||||||
| _itEffectCounter (_itEffect itm) == 0 = aSonarPulse cr w
|
& soundStart OnceSound (_crPos cr) click1S Nothing
|
||||||
& decreasecounter
|
| otherwise = w
|
||||||
| otherwise = decreasecounter w
|
& creatures . ix (_crID cr) . crInv . ix (fromJust $ _itInvPos itm)
|
||||||
where
|
. itUse . eqParams . eparamInt -~ 1
|
||||||
decreasecounter = creatures . ix (_crID cr) . crInv
|
|
||||||
. ix (fromJust $ _itInvPos itm) . itEffect . itEffectCounter %~ (\i -> (i - 1) `mod` 50)
|
|
||||||
|
|
||||||
defaultTargeting :: Targeting
|
defaultTargeting :: Targeting
|
||||||
defaultTargeting = Targeting
|
defaultTargeting = Targeting
|
||||||
|
|||||||
@@ -61,9 +61,10 @@ autoSonar = defaultEquipment
|
|||||||
{ _itType = RADAR
|
{ _itType = RADAR
|
||||||
, _itName = "AUTOSONAR"
|
, _itName = "AUTOSONAR"
|
||||||
, _itEquipPict = shapeForWrist (colorSH red $ upperPrismPoly 3 $ rectWH 2 2)
|
, _itEquipPict = shapeForWrist (colorSH red $ upperPrismPoly 3 $ rectWH 2 2)
|
||||||
, _itEffect = autoSonarEffect
|
|
||||||
, _itID = Nothing
|
, _itID = Nothing
|
||||||
} & itUse . eqSite .~ GoesOnWrist
|
} & itUse . eqSite .~ GoesOnWrist
|
||||||
|
& itUse . eqUse .~ autoSonarEffect
|
||||||
|
& itUse . eqParams .~ EquipCounter 0
|
||||||
{- |
|
{- |
|
||||||
Automatically sends out pulses that display walls. -}
|
Automatically sends out pulses that display walls. -}
|
||||||
autoRadar :: Item
|
autoRadar :: Item
|
||||||
@@ -71,9 +72,12 @@ autoRadar = defaultEquipment
|
|||||||
{ _itType = RADAR
|
{ _itType = RADAR
|
||||||
, _itName = "AUTORADAR"
|
, _itName = "AUTORADAR"
|
||||||
, _itEquipPict = shapeForWrist (colorSH yellow $ upperPrismPoly 3 $ rectWH 2 2)
|
, _itEquipPict = shapeForWrist (colorSH yellow $ upperPrismPoly 3 $ rectWH 2 2)
|
||||||
, _itEffect = autoRadarEffect
|
-- , _itEffect = autoRadarEffect
|
||||||
, _itID = Nothing
|
, _itID = Nothing
|
||||||
} & itUse . eqSite .~ GoesOnWrist
|
}
|
||||||
|
& itUse . eqSite .~ GoesOnWrist
|
||||||
|
& itUse . eqUse .~ autoRadarEffect
|
||||||
|
& itUse . eqParams .~ EquipCounter 0
|
||||||
|
|
||||||
shapeForWrist :: Shape -> Creature -> Item -> SPic
|
shapeForWrist :: Shape -> Creature -> Item -> SPic
|
||||||
shapeForWrist = pictureOnEquip . noPic . translateSH (V3 0 4 (-4))
|
shapeForWrist = pictureOnEquip . noPic . translateSH (V3 0 4 (-4))
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ Effects centered on creatures.
|
|||||||
These are typically item effects, and typical occur when an item is explictly used. -}
|
These are typically item effects, and typical occur when an item is explictly used. -}
|
||||||
module Dodge.Item.Weapon.UseEffect where
|
module Dodge.Item.Weapon.UseEffect where
|
||||||
import Dodge.Data
|
import Dodge.Data
|
||||||
|
import Dodge.Zone
|
||||||
import Picture
|
import Picture
|
||||||
import Geometry
|
import Geometry
|
||||||
import LensHelp
|
import LensHelp
|
||||||
@@ -31,7 +32,7 @@ mvBlip p col maxt t w pt =
|
|||||||
, Just $ pt & ptUpdate .~ mvBlip p col maxt (t-1)
|
, Just $ pt & ptUpdate .~ mvBlip p col maxt (t-1)
|
||||||
& ptDraw .~ ( const
|
& ptDraw .~ ( const
|
||||||
. setDepth (-0.5)
|
. setDepth (-0.5)
|
||||||
. setLayer BloomLayer
|
. setLayer DebugLayer
|
||||||
. uncurryV translate p
|
. uncurryV translate p
|
||||||
. color (withAlpha (fromIntegral t / fromIntegral maxt) col)
|
. color (withAlpha (fromIntegral t / fromIntegral maxt) col)
|
||||||
$ circleSolid 2 )
|
$ circleSolid 2 )
|
||||||
@@ -68,31 +69,31 @@ An outwardly increasing circle that displays walls, even those behind other wall
|
|||||||
radarPulseAt :: Point2 -> Particle
|
radarPulseAt :: Point2 -> Particle
|
||||||
radarPulseAt p = Particle
|
radarPulseAt p = Particle
|
||||||
{ _ptDraw = const blank
|
{ _ptDraw = const blank
|
||||||
, _ptUpdate = mvRadar 50 p
|
, _ptUpdate = mvRadar 100 p
|
||||||
}
|
}
|
||||||
mvRadar
|
mvRadar
|
||||||
:: Int -- ^ Timer
|
:: Int -- ^ Timer
|
||||||
-> Point2 -- ^ Center of expanding circle
|
-> Point2 -- ^ Center of expanding circle
|
||||||
-> World -> Particle -> (World, Maybe Particle)
|
-> World -> Particle -> (World, Maybe Particle)
|
||||||
mvRadar 0 _ w _ = (w, Nothing)
|
mvRadar 0 _ w _ = (w, Nothing)
|
||||||
mvRadar _ _ w _ = (w, Nothing)
|
--mvRadar _ _ w _ = (w, Nothing)
|
||||||
--mvRadar x p w pt = undefined
|
mvRadar x p w pt =
|
||||||
-- ( putBlips w
|
( putBlips w
|
||||||
-- , Just $ pt {_ptDraw = const pic ,_ptUpdate = mvRadar (x-1) p }
|
, Just $ pt {_ptDraw = const pic ,_ptUpdate = mvRadar (x-1) p }
|
||||||
-- )
|
)
|
||||||
-- where
|
where
|
||||||
-- pic = onLayerL [levLayer ShadowLayer, 1] $ pictures sweepPics
|
pic = setLayer DebugLayer $ pictures sweepPics
|
||||||
-- putBlips = over worldEvents ( over instantParticles (blips ++) . )
|
putBlips = over worldEvents ( over instantParticles (blips ++) . )
|
||||||
-- blips = map (\bp -> blipAt bp (withAlpha (0.5*globalAlpha) red) 50) circPoints
|
blips = map (\bp -> blipAt bp (withAlpha (0.5*globalAlpha) red) 50) circPoints
|
||||||
-- circPoints = mapMaybe (\wl -> uncurry collidePointCircCorrect (_wlLine wl) r p)
|
circPoints = mapMaybe (\wl -> uncurry (intersectCircSegFirst p r) (_wlLine wl))
|
||||||
-- $ map (over wlLine swp) (IM.elems $ wallsAlongCirc p r w)
|
$ map (over wlLine swp) (IM.elems $ wallsAlongCirc p r w)
|
||||||
-- ++ IM.elems (wallsAlongCirc p r w)
|
++ IM.elems (wallsAlongCirc p r w)
|
||||||
-- swp (a,b) = (b,a)
|
swp (a,b) = (b,a)
|
||||||
-- r = fromIntegral (800 - x*16)
|
r = fromIntegral (400 - x*4)
|
||||||
-- sweepPics = [--colHelper 0.1 $ uncurry translate p $ thickCircle r 15
|
sweepPics = [colHelper 0.1 $ uncurryV translate p $ thickCircle r 15
|
||||||
-- --,colHelper 0.06 $ uncurry translate p $ thickCircle (r-5) 5
|
,colHelper 0.06 $ uncurryV translate p $ thickCircle (r-5) 5
|
||||||
-- --,colHelper 0.03 $ uncurry translate p $ thickCircle (r-10) 5
|
,colHelper 0.03 $ uncurryV translate p $ thickCircle (r-10) 5
|
||||||
-- ]
|
]
|
||||||
-- globalAlpha | x > 10 = 1
|
globalAlpha | x > 10 = 1
|
||||||
-- | otherwise = fromIntegral x / 10
|
| otherwise = fromIntegral x / 10
|
||||||
-- --colHelper y = color (withAlpha (y * globalAlpha) red)
|
colHelper y = color (withAlpha (y * globalAlpha) red)
|
||||||
|
|||||||
Reference in New Issue
Block a user