Allow for bullet drag

This commit is contained in:
2021-12-02 18:29:46 +00:00
parent 85ededc158
commit 8b8d75b016
35 changed files with 362 additions and 228 deletions
+2 -2
View File
@@ -20,8 +20,8 @@ data Annotation g
| TreasureAno [Creature] [Item]
| AnoApplyInt Int (Int -> State g (SubCompTree Room))
| PassthroughLockKeyLists Int
[(Int -> State g (SubCompTree Room), State g ItemIdentity)]
[(ItemIdentity, State g (SubCompTree Room))]
[(Int -> State g (SubCompTree Room), State g CombineType)]
[(CombineType, State g (SubCompTree Room))]
-- | SetLabel Int (State g Room)
-- | UseLabel Int (State g Room)
| ChainAnos [[Annotation g]]
+17 -7
View File
@@ -1,13 +1,23 @@
{-# LANGUAGE TupleSections #-}
module Dodge.Combine
(
) where
--import Dodge.Data
module Dodge.Combine where
import Dodge.Data
--import Dodge.Combine.Data
--import Dodge.Combine.Combinations
import Dodge.Combine.Combinations
import Dodge.Item.Weapon.BulletGuns
import Dodge.Item.Craftable
--import Data.Bifunctor
import Data.Bifunctor
--import qualified Data.IntMap.Strict as IM
--import qualified Data.IntSet as IS
--import qualified Data.Map.Strict as M
import qualified Data.Map.Strict as M
pureCombine :: [ (M.Map CombineType Int, Item) ]
pureCombine = map (first toMultiset)
[ p [PIPE,HARDWARE] bangStick
, p [LONGPIPE,HARDWARE] bangCane
, p [VERYLONGPIPE,HARDWARE] bangRod
, p [PIPE,PIPE] $ makeTypeCraft LONGPIPE
, p [LONGPIPE,PIPE] $ makeTypeCraft VERYLONGPIPE
]
where
p = (,)
+17 -21
View File
@@ -11,40 +11,36 @@ import qualified Data.Map.Strict as M
import Control.Monad
import Data.Maybe
combineList :: IM.IntMap ItemCombineType -> [([Int],ItemCombineType)]
combineList :: IM.IntMap CombineType -> [([Int],CombineType)]
combineList m = mapMaybe (pushoutmaybe . second (combine . toMultiset) . unzip)
. powlist
. powlistN 4
$ IM.toList m
where
pushoutmaybe (_,Nothing) = Nothing
pushoutmaybe (x,Just y) = Just (x,y)
powlistN :: Int -> [a] ->[[a]]
powlistN _ [] = [[]]
powlistN n (x:xs)
| n <=0 = [[]]
| otherwise = ((x:) <$> powlistN (n-1) xs) ++ powlistN n xs
-- expo
powlist :: [a] -> [[a]]
powlist = filterM (const [True,False])
combine :: M.Map ItemCombineType Int -> Maybe ItemCombineType
combine :: M.Map CombineType Int -> Maybe CombineType
combine m = lookup m combinations
toMultiset :: Ord a => [a] -> M.Map a Int
toMultiset = foldr (uncurry $ M.insertWith (+)) M.empty . map (,1)
combinations :: [(M.Map ItemCombineType Int, ItemCombineType)]
combinations :: [(M.Map CombineType Int, CombineType)]
combinations = map (first toMultiset)
[ ( [ TPistol, TPipe, THardware ] , TRifle )
, ( [ NoCombineType ] , TPistol )
, ( [ TRifle, THardware ] , TPistol )
, ( [ TPistol, TPistol, THardware ] , TSpreadGun 2 )
, ( [ TSpreadGun 2, TPistol, THardware ] , TSpreadGun 3 )
, ( [ TSpreadGun 3, TPistol, THardware ] , TSpreadGun 4 )
, ( [ TSpreadGun 4, TPistol, THardware ] , TSpreadGun 5 )
, ( [ TPistol, TAutoGun, THardware ] , TLtAutoGun )
, ( [ TLtAutoGun, TPipe, THardware ] , TAutoGun )
, ( [ TRifle, TRifle, THardware ] , TMultGun 2 )
, ( [ TMultGun 2, TRifle, THardware ] , TMultGun 3 )
, ( [ TMultGun 3, TRifle, THardware ] , TMultGun 4 )
, ( [ TMultGun 4, TRifle, THardware ] , TMultGun 5 )
, ( [ TLtAutoGun, TPipe, THardware ] , TAutoGun )
, ( [ TPistol, TTube, THardware] , TLauncher 1 )
, ( [ TLauncher 1, TTube, TPistol, THardware] , TLauncher 2)
, ( [ TLauncher 2, TTube, TPistol, THardware] , TLauncher 3)
[ ( [ PIPE, HARDWARE ] , BANGSTICK )
, ( [ LONGPIPE, HARDWARE ] , BANGCANE )
, ( [ VERYLONGPIPE, HARDWARE ] , BANGROD )
, ( [ PIPE, PIPE ] , LONGPIPE )
, ( [ LONGPIPE, PIPE ] , VERYLONGPIPE )
]
+44 -3
View File
@@ -1,9 +1,50 @@
module Dodge.Combine.Data
(ItemCombineType (..)
(CombineType (..)
)
where
data ItemCombineType
= TPipe
data CombineType
= NOTDEFINED
-- Weapons
| BANGSTICK
| BANGCANE
| BANGROD
| PISTOL
| HVAUTOGUN
| LTAUTOGUN
| MINIGUN
| AUTOGUN
| SPREADGUN
| MULTGUN
| LONGGUN
| TESLAGUN
| LASGUN
| TRACTORGUN
| LAUNCHER
| SPRAYER
| SQUIRTER
| DRONELAUNCHER
| GRENADE
| REMOTEBOMB
-- Utility items
| BOOSTER
| REWINDER
| BLINKER
| FORCEFIELD
| SHRINKER
-- Equipment
| RADAR
| MAGSHIELD
| FLAMESHIELD
| FRONTARMOUR
| FLATSHIELD
| JETPACK
-- Crafting
| PIPE
| LONGPIPE
| VERYLONGPIPE
| HARDWARE
| SPRING
| TPipe
| NoCombineType
| TLongPipe
| TVeryLongPipe
+3 -3
View File
@@ -106,8 +106,8 @@ creatureTurnToward p turnSpeed cr
equipSpeed :: Item -> Float
equipSpeed _ = 1
{- | Speed modifier of an item when aiming. -}
equipAimSpeed :: Item -> Float
equipAimSpeed :: Item -> Float -- TODO remove/rethink
equipAimSpeed it
| _itIdentity it == FrontArmour = 0.5
| _itIdentity it == FlameShield = 0.5
| _itCombineType it == FRONTARMOUR = 0.5
| _itCombineType it == FLAMESHIELD = 0.5
| otherwise = 1
+2 -2
View File
@@ -4,7 +4,7 @@ module Dodge.Creature.Impulse.UseItem
, useLeftItem
) where
import Dodge.Data
import Dodge.Inventory
--import Dodge.Inventory
import qualified Data.IntMap.Strict as IM
import Control.Lens
@@ -22,7 +22,7 @@ tryUseItem cr' w = case w ^? creatures . ix (_crID cr') of
Nothing -> w
itemEffect :: Creature -> Item -> World -> World
itemEffect cr Consumable{_cnEffect=eff } w = maybe w (rmSelectedInvItem (_crID cr)) (eff (_crID cr) w)
--itemEffect cr Consumable{_cnEffect=eff } w = maybe w (rmSelectedInvItem (_crID cr)) (eff (_crID cr) w)
itemEffect cr it w = case it ^? itUse of
Just RightUse {_rUse = eff,_useMods = usemods} -> foldr ($) eff usemods it cr w
Just LeftUse {} -> w
+1 -1
View File
@@ -11,7 +11,7 @@ import Control.Lens
crIsArmouredFrom :: Point2 -> Creature -> Bool
crIsArmouredFrom p cr
= p /= _crPos cr
&& any (\it -> it ^? itIdentity == Just FrontArmour) (_crInv cr)
&& any (\it -> it ^? itCombineType == Just FRONTARMOUR) (_crInv cr)
&& angleVV (unitVectorAtAngle $ _crDir cr) (p -.- _crPos cr) < pi/2
-- even though angleVV can generate NaN, the comparison seems to deal with it
+2 -1
View File
@@ -110,7 +110,7 @@ movementSideEff cr w
_ -> w
| otherwise = footstepSideEffect cr w
where
hasJetPack = any (\it -> it ^? itIdentity == Just JetPack) $ _crInv cr
hasJetPack = any (\it -> it ^? itCombineType == Just JETPACK) $ _crInv cr
oldPos = _crOldPos cr
momentum' = 0.97 *.* (_crPos cr -.- _crOldPos cr)
momentum'' | magV momentum' > 3 = 3 *.* normalizeV momentum'
@@ -158,6 +158,7 @@ weaponReloadSounds cr w = case cr ^? crInv . ix (_crInvSel cr) . itConsumption o
ActivePartial{} | _reloadState am == Nothing' -> w
ActivePartial{} -> soundContinue (CrReloadSound cid) (_crPos cr) reloadS (Just 1) w
Just ChargeableAmmo {} -> w
Just NoConsumption {} -> w
Just ItemItselfConsumable {} -> w
Nothing -> w
where
+44 -37
View File
@@ -330,16 +330,16 @@ data ItemConsumption
{ _itMaxStack' :: Int
, _itAmount' :: Int
}
| NoConsumption
data Item
= Weapon
= Item
{ _itName :: String
, _itConsumption :: ItemConsumption
, _itUse :: ItemUse
, _itFloorPict :: Item -> SPic
, _itEquipPict :: Creature -> Int -> SPic
, _itScroll :: Float -> Creature -> Item -> Item
, _itIdentity :: ItemIdentity
, _itCombineType :: ItemCombineType
, _itCombineType :: CombineType
, _itAttachment :: ItAttachment
, _itID :: Maybe Int
, _itEffect :: ItEffect
@@ -352,43 +352,44 @@ data Item
, _itParams :: ItemParams
, _itTweaks :: ItemTweaks
}
| Consumable
{ _itName :: String
, _itMaxStack :: Int
, _itAmount :: Int
, _cnEffect :: Int -> World -> Maybe World
, _itFloorPict :: Item -> SPic
, _itEquipPict :: Creature -> Int -> SPic
, _itIdentity :: ItemIdentity
, _itID :: Maybe Int
, _itInvSize :: Int
, _itInvDisplay :: Item -> [String]
, _itInvColor :: Color
, _itEffect :: ItEffect
, _itCurseStatus :: CurseStatus
, _itDimension :: ItemDimension
}
| Craftable
{ _itName :: String
, _itMaxStack :: Int
, _itAmount :: Int
, _itFloorPict :: Item -> SPic
, _itEquipPict :: Creature -> Int -> SPic
, _itIdentity :: ItemIdentity
, _itID :: Maybe Int
, _itInvSize :: Int
, _itInvDisplay :: Item -> [String]
, _itInvColor :: Color
, _itCurseStatus :: CurseStatus
, _itDimension :: ItemDimension
}
-- | Consumable
-- { _itName :: String
-- , _itMaxStack :: Int
-- , _itAmount :: Int
-- , _cnEffect :: Int -> World -> Maybe World
-- , _itFloorPict :: Item -> SPic
-- , _itEquipPict :: Creature -> Int -> SPic
-- , _itIdentity :: ItemIdentity
-- , _itID :: Maybe Int
-- , _itInvSize :: Int
-- , _itInvDisplay :: Item -> [String]
-- , _itInvColor :: Color
-- , _itEffect :: ItEffect
-- , _itCurseStatus :: CurseStatus
-- , _itDimension :: ItemDimension
-- }
-- | Craftable
-- { _itName :: String
-- , _itMaxStack :: Int
-- , _itAmount :: Int
-- , _itFloorPict :: Item -> SPic
-- , _itEquipPict :: Creature -> Int -> SPic
-- , _itIdentity :: ItemIdentity
-- , _itID :: Maybe Int
-- , _itInvSize :: Int
-- , _itInvDisplay :: Item -> [String]
-- , _itInvColor :: Color
-- , _itCurseStatus :: CurseStatus
-- , _itDimension :: ItemDimension
-- }
| Equipment
{ _itName :: String
, _itFloorPict :: Item -> SPic
, _itEquipPict :: Creature -> Int -> SPic
, _itIdentity :: ItemIdentity
-- , _itIdentity :: ItemIdentity
, _itEffect :: ItEffect
, _itID :: Maybe Int
, _itCombineType :: CombineType
, _itZoom :: ItZoom
, _itInvSize :: Int
, _itInvDisplay :: Item -> [String]
@@ -406,9 +407,10 @@ data Item
, _itUse :: ItemUse
-- , _itZoom :: ItZoom
, _itEquipPict :: Creature -> Int -> SPic
, _itIdentity :: ItemIdentity
--, _itIdentity :: ItemIdentity
, _itID :: Maybe Int
, _itAttachment :: ItAttachment
, _itCombineType :: CombineType
, _itInvSize :: Int
, _itInvDisplay :: Item -> [String]
, _itInvColor :: Color
@@ -475,9 +477,10 @@ data Particle
, _ptColor :: Color
}
| BulletPt
{ _ptDraw :: Particle -> Picture
{ _ptDraw :: Particle -> Picture
, _ptUpdate :: World -> Particle -> (World, Maybe Particle)
, _btVel' :: Point2
, _btVel' :: Point2
, _btDrag :: Float
, _btColor' :: Color
, _btTrail' :: [Point2]
, _btPassThrough' :: Maybe Int
@@ -547,6 +550,9 @@ data GunBarrels
{ _brlSpread :: BarrelSpread
, _brlNum :: Int
}
| RotBarrel
{ _brlNum :: Int
}
| SingleBarrel {_brlInaccuracy :: Float}
data ItemParams
@@ -559,6 +565,7 @@ data ItemParams
| Refracting {_phaseV :: Float}
| BulletShooter
{ _muzVel :: Float
, _rifling :: Float
, _bore :: Float
, _gunBarrels :: GunBarrels
}
+18 -29
View File
@@ -131,10 +131,11 @@ defaultState = CrSt
}
defaultEquipment :: Item
defaultEquipment = Equipment
{ _itIdentity = Generic
, _itCurseStatus = Uncursed
{ _itCurseStatus = Uncursed
, _itCombineType = NOTDEFINED
, _itName = "genericEquipment"
, _itFloorPict = \_ -> (,) emptySH $ setLayer 0 $ onLayer FlItLayer $ polygon $ map toV2 [(-3,-3),(-3,3),(3,3),(3,-3)]
-- ,_itIdentity = Generic
, _itFloorPict = \_ -> noShape $ setLayer 0 $ onLayer FlItLayer $ polygon $ map toV2 [(-3,-3),(-3,3),(3,3),(3,-3)]
, _itEquipPict = \_ _ -> (,) emptySH blank
, _itEffect = NoItEffect
, _itID = Nothing
@@ -147,21 +148,26 @@ defaultEquipment = Equipment
defaultItZoom :: ItZoom
defaultItZoom = ItZoom 20 0.2 1
defaultConsumable :: Item
defaultConsumable = Consumable
{ _itIdentity = Generic
defaultConsumable = Item
{ _itUse = NoUse
-- , _itIdentity = Generic
, _itInvSize = 1
, _itCurseStatus = Uncursed
, _itName = "genericConsumable"
, _itMaxStack = 9
, _itAmount = 1
, _cnEffect = \_ _ -> Nothing
, _itFloorPict = \_ -> (,) emptySH $ onLayer FlItLayer $ color blue $ circleSolid 3
, _itEquipPict = \_ _ -> (,) emptySH blank
, _itConsumption = ItemItselfConsumable {_itMaxStack' = 9, _itAmount' = 1}
, _itFloorPict = \_ -> noShape $ onLayer FlItLayer $ color blue $ circleSolid 3
, _itEquipPict = \_ _ -> mempty
, _itID = Nothing
, _itInvColor = blue
, _itInvDisplay = \it -> [_itName it ++ " x" ++ show (_itAmount it)]
, _itInvDisplay = \it -> [_itName it ++ " x" ++ show (_itAmount' $ _itConsumption it)]
, _itEffect = NoItEffect
, _itScroll = \_ _ -> id
, _itAttachment = NoItAttachment
, _itCombineType = NoCombineType
, _itTargeting = Nothing
, _itParams = NoParams
, _itDimension = defaultItemDimension
, _itTweaks = NoTweaks
}
defaultApplyDamage :: [DamageType] -> Creature -> (World -> World, Creature)
defaultApplyDamage ds cr = (id, doPoisonDam $ foldl' (flip $ \d c -> snd $ applyIndividualDamage d c) cr ds')
@@ -193,24 +199,7 @@ applyIndividualDamage (PushDam amount pback) cr
applyIndividualDamage dt cr
= ( id , over crHP (\hp -> hp - _dmAmount dt) cr )
defaultFlIt :: FloorItem
defaultFlIt = FlIt {_flItRot=0,_flIt = defaultIt, _flItPos = V2 0 0, _flItID = 0}
defaultIt :: Item
defaultIt = Consumable
{ _itIdentity = Medkit25
, _itInvSize = 1
, _itDimension = defaultItemDimension
, _itCurseStatus = Uncursed
, _itName = "defaultIt"
, _itMaxStack = 3
, _itAmount = 2
, _cnEffect = const return
, _itFloorPict = \_ -> (,) emptySH $ onLayer FlItLayer $ polygon $ square 3
, _itEquipPict = \_ _ -> (,) emptySH blank
, _itID = Nothing
, _itInvDisplay = (:[]) . _itName
, _itInvColor = blue
, _itEffect = NoItEffect
}
defaultFlIt = FlIt {_flItRot=0,_flIt = defaultConsumable, _flItPos = V2 0 0, _flItID = 0}
defaultMachine :: Machine
defaultMachine = Machine
{ _mcID = 0
+28 -2
View File
@@ -82,11 +82,11 @@ defaultAimParams = AimParams
}
defaultGun :: Item
defaultGun = Weapon
defaultGun = Item
{ _itName = "default"
, _itCombineType = NoCombineType
, _itCurseStatus = Uncursed
, _itIdentity = Pistol
-- , _itIdentity = Pistol
, _itConsumption = defaultAmmo
, _itUse = defaultrUse
, _itFloorPict = const $ noPic $ colorSH green (prismPoly
@@ -107,6 +107,32 @@ defaultGun = Weapon
, _itDimension = defaultItemDimension
, _itTweaks = NoTweaks
}
defaultCraftable :: Item
defaultCraftable = Item
{ _itName = "default"
, _itCombineType = NoCombineType
, _itCurseStatus = Uncursed
-- , _itIdentity = Generic
, _itConsumption = NoConsumption
, _itUse = NoUse
, _itFloorPict = const $ noPic $ colorSH green (prismPoly
(map (addZ 3) $ rectNESW 3 3 (-3) (-3))
(map (addZ 0) $ rectNESW 5 3 (-5) (-7))
)
-- , _itZoom = ItZoom 20 0.2 1
, _itEquipPict = pictureWeaponOnAim
, _itScroll = \_ _ -> id
, _itAttachment = NoItAttachment
, _itID = Nothing
, _itEffect = NoItEffect
, _itInvDisplay = \it -> take (_itInvSize it) (_itName it : repeat "*")
, _itInvColor = green
, _itInvSize = 1
, _itTargeting = Nothing
, _itParams = NoParams
, _itDimension = defaultItemDimension
, _itTweaks = NoTweaks
}
defaultItemDimension :: ItemDimension
defaultItemDimension = ItemDimension
{ _itDim = V3 4 4 4
+2 -2
View File
@@ -10,7 +10,7 @@ import Shape
keyToken :: Int -> Item
keyToken n = defaultEquipment
{ _itIdentity = Generic
{ _itCombineType = NOTDEFINED
, _itName = "KEYTOKEN "++show n
, _itMaxStack = 5
, _itAmount = 1
@@ -31,7 +31,7 @@ keyPic = color green $
latchkey :: Int -> Item
latchkey n = defaultEquipment
{ _itIdentity = Generic
{ _itCombineType = NOTDEFINED
, _itName = "KEY "++show n
, _itMaxStack = 1
, _itAmount = 1
+8 -6
View File
@@ -3,21 +3,24 @@ import Dodge.Data
import Dodge.Picture.Layer
import Dodge.Default
import Dodge.SoundLogic
import Dodge.Inventory
import Shape
--import ShapePicture
import Dodge.Item.Draw
import Picture
import Data.Maybe
import Control.Lens
import qualified Data.IntMap.Strict as IM
medkit :: Int -> Item
medkit i = defaultConsumable
{ _itIdentity = Medkit25
, _itName = "MEDKIT" ++ show i
, _itMaxStack = 9
, _itAmount = 1
, _cnEffect = heal i
{ _itName = "MEDKIT" ++ show i
, _itUse = LeftUse
{_lUse = \cr invid w -> fromMaybe w (heal 25 (_crID cr) $ rmInvItem (_crID cr) invid w)
,_useDelay = NoDelay
,_useHammer = HasHammer HammerUp
}
, _itFloorPict = \_ -> (,) emptySH $ setLayer 0 . onLayer FlItLayer . color blue $ circleSolid 3
, _itEquipPict = pictureItem $ (,) emptySH $ color blue $ circleSolid 3
, _itID = Nothing
@@ -31,4 +34,3 @@ heal hp n w | _crHP (_creatures w IM.! n) >= 10000 = Nothing
& creatures . ix n . crHP %~ min 10000 . (+ hp)
where
cr = _creatures w IM.! n
+11 -17
View File
@@ -1,23 +1,17 @@
module Dodge.Item.Craftable where
import Dodge.Data
import Dodge.Default.Weapon
import Dodge.Picture.Layer
import Picture
import Geometry
--import Dodge.Picture.Layer
--import Picture
--import Geometry
pipe :: Item
pipe = Craftable
{ _itIdentity = Generic
, _itInvSize = 1
, _itDimension = defaultItemDimension
makeTypeCraft :: CombineType -> Item
makeTypeCraft ct = defaultCraftable
{ _itInvSize = 1
, _itCurseStatus = Uncursed
, _itName = "PIPE"
, _itMaxStack = 3
, _itAmount = 3
, _itFloorPict = \_ -> (,) mempty
$ onLayer FlItLayer $ polygon $ map toV2 [(-3,-3),(-3,3),(3,3),(3,-3)]
, _itEquipPict = \_ _ -> mempty
, _itID = Nothing
, _itInvDisplay = (:[]) . _itName
, _itInvColor = green
, _itName = show ct
, _itCombineType = ct
, _itConsumption = ItemItselfConsumable 3 3
}
pipe :: Item
pipe = makeTypeCraft PIPE
+35 -35
View File
@@ -13,40 +13,40 @@ data HammerPosition
| HammerUp
deriving
(Eq, Ord, Show)
data ItemIdentity
= Pistol
| SpreadGun
| MultGun
| HvAutoGun
| AutoGun
| LtAutoGun
| MiniGun
| Medkit25
| MagShield
| FrontArmour
| JetPack
| FlameShield
| Generic
| SparkGun
| ShatterGun
| LongGun
| Flamethrower
| Blinker
| Rewinder
| Grenade
| RemoteBomb
| TeslaGun
| LasGun
| ForceFieldGun
| GrapGun
| TractorGun
| Launcher
| RemoteLauncher
| LightningGun
| PoisonSprayer
| FlatShield
deriving
(Eq,Show,Ord,Enum)
--data ItemIdentity
-- = Pistol
-- | SpreadGun
-- | MultGun
-- | HvAutoGun
-- | AutoGun
-- | LtAutoGun
-- | MiniGun
-- | Medkit25
-- | MagShield
-- | FrontArmour
-- | JetPack
-- | FlameShield
-- | Generic
-- | SparkGun
-- | ShatterGun
-- | LongGun
-- | Flamethrower
-- | Blinker
-- | Rewinder
-- | Grenade
-- | RemoteBomb
-- | TeslaGun
-- | LasGun
-- | ForceFieldGun
-- | GrapGun
-- | TractorGun
-- | Launcher
-- | RemoteLauncher
-- | LightningGun
-- | PoisonSprayer
-- | FlatShield
-- deriving
-- (Eq,Show,Ord,Enum)
data AimStance
= TwoHandTwist
| TwoHandFlat
@@ -85,7 +85,7 @@ data UseDelay -- should just be Delay
data BarrelSpread
= AlignedBarrels
| SpreadBarrels {_spreadAngle :: Float}
| RotatingBarrels {_rotatingBarrelAccuracy :: Float}
| RotatingBarrels {_rotatingBarrelInaccuracy :: Float}
makeLenses ''BarrelSpread
makeLenses ''HammerType
makeLenses ''ItZoom
+5 -5
View File
@@ -18,7 +18,7 @@ import Control.Lens
magShield :: Item
magShield = defaultEquipment
{ _itIdentity = MagShield
{ _itCombineType = MAGSHIELD
, _itName = "MAGSHIELD"
, _itFloorPict = \_ -> (,) emptySH $ onLayer FlItLayer $ polygon $ map toV2 [(-3,-3),(-3,3),(3,3),(3,-3)]
, _itEquipPict = \_ _ -> (,) emptySH blank
@@ -26,7 +26,7 @@ magShield = defaultEquipment
}
flameShield :: Item
flameShield = defaultEquipment
{ _itIdentity = FlameShield
{ _itCombineType = FLAMESHIELD
, _itName = "FLAMESHIELD"
, _itFloorPict = \_ -> (,) emptySH $ onLayer FlItLayer $ polygon $ map toV2 [(-3,-3),(-3,3),(3,3),(3,-3)]
, _itEquipPict = \cr _ -> (,) emptySH $ onLayer CrLayer $ pictures [color cyan $ circle (_crRad cr+2)]
@@ -35,7 +35,7 @@ flameShield = defaultEquipment
{- | Slows you down, blocks forward projectiles. -}
frontArmour :: Item
frontArmour = defaultEquipment
{ _itIdentity = FrontArmour
{ _itCombineType = FRONTARMOUR
, _itName = "FARMOUR"
, _itFloorPict = \_ -> (,) emptySH $ onLayer FlItLayer $ translate 0 (-5) $ pictures
[color (greyN 0.1) $ thickArc 0 (pi/2) 10 5
@@ -53,7 +53,7 @@ flatShield = defaultEquipment
{ _itEquipPict = pictureWeaponOnAim' flatShieldEquipSPic -- this will not work any more because the shield has no aim stance
, _itEffect = effectOnOffEquip createShieldWall removeShieldWall
, _itName = "SHIELD"
, _itIdentity = FlatShield
, _itCombineType = FLATSHIELD
}
flatShieldEquipSPic :: Item -> SPic
flatShieldEquipSPic _ =
@@ -131,7 +131,7 @@ effectOnOffEquip f f' = ItInvEffectID
{- | Increases speed, reduces friction, cannot only move forwards. -}
jetPack :: Item
jetPack = defaultEquipment
{ _itIdentity = JetPack
{ _itCombineType = JETPACK
, _itName = "JETPACK"
, _itFloorPict = \_ -> (,) emptySH $ onLayer FlItLayer $ color yellow $ polygon $ map toV2 [(-3,-3),(-3,3),(3,3),(3,-3)]
, _itEquipPict = \_ _ -> (,) emptySH $ onLayer CrLayer
+11 -7
View File
@@ -9,8 +9,9 @@ module Dodge.Item.Weapon.AmmoParams
import Dodge.Data
import Dodge.Particle.Bullet.Spawn
import Geometry
import LensHelp
import Control.Lens
--import Control.Lens
useAmmoParamsRate :: Int
-> HammerType
@@ -32,28 +33,30 @@ defaultAimParams = AimParams
}
useAmmoParams :: Item -> Creature -> World -> World
useAmmoParams it = withVelWthHiteff (muzvel *.* _amBulVel b) (_amBulWth b) (_amBulEff b)
useAmmoParams it = withVelWthHiteff (muzvel *.* _amBulVel b) (_rifling $ _itParams it) (_amBulWth b) (_amBulEff b)
where
muzvel = _muzVel $ _itParams it
b = _aoType $ _itConsumption it
useAmmoParamsVelMod :: Float -> Item -> Creature -> World -> World
useAmmoParamsVelMod vfact it = withDelayedVelWthHiteff vfact (_amBulVel b) (_amBulWth b) (_amBulEff b)
useAmmoParamsVelMod vfact it = withDelayedVelWthHiteff vfact (_amBulVel b) (_rifling $ _itParams it)
(_amBulWth b) (_amBulEff b)
where
b = _aoType $ _itConsumption it
{- | Creates a bullet with a given velocity, width, and 'HitEffect' -}
withVelWthHiteff
:: Point2 -- ^ Velocity, x direction is forward with respect to the creature
-> Float -- ^ drag
-> Float -- ^ Bullet width
-> HitEffect -- ^ Bullet effect when hitting creature, wall etc
-> Creature
-> World
-> World
withVelWthHiteff vel width hiteff cr = over particles (newbul : )
withVelWthHiteff vel drag width hiteff cr = particles .:~ newbul
where
cid = _crID cr
newbul = aGenBulAt (Just cid) pos (rotateV dir vel) hiteff width
newbul = aGenBulAt (Just cid) pos (rotateV dir vel) drag hiteff width
dir = _crDir cr
pos = _crPos cr +.+ _crRad cr *.* unitVectorAtAngle (_crDir cr)
@@ -61,15 +64,16 @@ withVelWthHiteff vel width hiteff cr = over particles (newbul : )
withDelayedVelWthHiteff
:: Float -- ^ Velocity factor for first step
-> Point2 -- ^ Velocity, x direction is forward with respect to the creature
-> Float -- ^ Drag
-> Float -- ^ Bullet width
-> HitEffect -- ^ Bullet effect when hitting creature, wall etc
-> Creature -- ^ Creature id
-> World
-> World
withDelayedVelWthHiteff vfact vel width hiteff cr = over particles (newbul : )
withDelayedVelWthHiteff vfact vel drag width hiteff cr = particles .:~ newbul
where
cid = _crID cr
newbul = aDelayedBulAt vfact (Just cid) pos (rotateV dir vel) hiteff width
newbul = aDelayedBulAt vfact (Just cid) pos (rotateV dir vel) drag hiteff width
dir = _crDir cr
pos = _crPos cr +.+ _crRad cr *.* unitVectorAtAngle (_crDir cr)
+4 -3
View File
@@ -36,7 +36,8 @@ import qualified Data.IntMap.Strict as IM
teslaGun :: Item
teslaGun = defaultGun
{ _itName = "TESLA"
, _itIdentity = TeslaGun
, _itCombineType = TESLAGUN
-- , _itIdentity = TeslaGun
, _itConsumption = defaultAmmo
{ _ammoMax = 200
, _ammoLoaded = 200
@@ -63,7 +64,7 @@ teslaGunPic _ = noPic $ colorSH blue $
lasGun :: Item
lasGun = defaultAutoGun
{ _itName = "LASGUN ////"
, _itIdentity = LasGun
, _itCombineType = LASGUN
, _itConsumption = defaultAmmo
{ _ammoMax = 200
, _ammoLoaded = 200
@@ -119,7 +120,7 @@ lasGunPic it =
tractorGun :: Item
tractorGun = defaultAutoGun
{ _itName = "TRACTORGUN"
, _itIdentity = TractorGun
, _itCombineType = TRACTORGUN
, _itConsumption = defaultAmmo
{ _ammoMax = 10000
, _ammoLoaded = 10000
+1 -1
View File
@@ -112,7 +112,7 @@ maxT = 20
boosterGun :: Item
boosterGun = defaultGun
{ _itName = "BOOSTER"
, _itIdentity = Blinker
, _itCombineType = BOOSTER
, _itConsumption = defaultAmmo
{ _ammoMax = 100
, _ammoLoaded = 100
+1 -1
View File
@@ -37,7 +37,7 @@ bounceBullet = BulletAmmo
{ _amString = "BOUNCING"
, _amBulEff = destroyOnImpact bulHitCr bulBounceWall
, _amBulWth = 2
, _amBulVel = V2 10 0
, _amBulVel = V2 40 0
}
ltBullet :: AmmoType
ltBullet = BulletAmmo
+61 -8
View File
@@ -1,5 +1,8 @@
module Dodge.Item.Weapon.BulletGuns
( pistol
, bangStick
, bangRod
, bangCane
, autoGun
, multGun
, miniGun
@@ -36,7 +39,7 @@ import Control.Lens
autoGun :: Item
autoGun = defaultAutoGun
{ _itName = "AUTOGUN"
, _itIdentity = AutoGun
, _itCombineType = AUTOGUN
, _itConsumption = defaultAmmo
{ _aoType = basicBullet
, _ammoMax = 30
@@ -72,6 +75,7 @@ autoGun = defaultAutoGun
, _itInvDisplay = basicWeaponDisplay
, _itParams = BulletShooter
{ _muzVel = 1
, _rifling = 0.9
, _bore = 2
, _gunBarrels = SingleBarrel 0.1
}
@@ -86,11 +90,48 @@ autoGunPic it = noPic $
<> translateSHf 0 (-1) (rotateSHx (negate $ pi/4) . upperPrismPoly 2 $ rectNESW (negate $ 3 + 0.25 * x) 0 3 (-5))
where
x = fromIntegral $ _ammoLoaded $ _itConsumption it
bangStick :: Item
bangStick = defaultGun
{ _itName = "BANGSTICK"
, _itCombineType = BANGSTICK
, _itConsumption = defaultAmmo
{ _aoType = basicBullet
, _ammoMax = 1
, _ammoLoaded = 1
, _reloadTime = 20
, _reloadType = ActivePartial 1
}
, _itUse = useAmmoParamsRate 8 upHammer
[ ammoCheckI
, hammerCheckI
, useTimeCheck
, withSoundStart tap3S
, useAmmoAmount 1
, applyInaccuracy
, withMuzFlareI
]
, _itFloorPict = pistolPic
-- , _itZoom = defaultItZoom
, _itEquipPict = pictureWeaponAim pistolPic
, _itID = Nothing
, _itInvDisplay = basicWeaponDisplay
, _itInvColor = white
, _itTargeting = Nothing
, _itParams = BulletShooter
{ _muzVel = 0.8
, _rifling = 0.8
, _bore = 2
, _gunBarrels = SingleBarrel 0.05
}
, _itTweaks = defaultBulletSelTweak
}
bangCane = bangStick
bangRod = bangCane
pistol :: Item
pistol = defaultGun
{ _itName = "PISTOL"
, _itIdentity = Pistol
, _itCombineType = PISTOL
, _itConsumption = defaultAmmo
{ _aoType = basicBullet
, _ammoMax = 15
@@ -116,6 +157,7 @@ pistol = defaultGun
, _itTargeting = Nothing
, _itParams = BulletShooter
{ _muzVel = 0.8
, _rifling = 0.8
, _bore = 2
, _gunBarrels = SingleBarrel 0.05
}
@@ -138,7 +180,7 @@ bulletClip x = rotateSHx (negate $ pi/4) . upperPrismPoly 2 $ rectNESW 3 0 (3 -
hvAutoGun :: Item
hvAutoGun = defaultAutoGun
{ _itName = "AUTO-HV"
, _itIdentity = HvAutoGun
, _itCombineType = HVAUTOGUN
, _itConsumption = defaultAmmo
{ _aoType = hvBullet
, _ammoMax = 100
@@ -178,7 +220,7 @@ hvAutoGunPic it =
ltAutoGun :: Item
ltAutoGun = defaultAutoGun
{ _itName = "AUTO-LT"
, _itIdentity = LtAutoGun
, _itCombineType = LTAUTOGUN
, _itConsumption = defaultAmmo
{ _aoType = ltBullet
, _ammoMax = 25
@@ -198,6 +240,7 @@ ltAutoGun = defaultAutoGun
, _itFloorPict = ltAutoGunPic
, _itParams = BulletShooter
{ _muzVel = 1
, _rifling = 0.8
, _bore = 2
, _gunBarrels = SingleBarrel autogunSpread
}
@@ -217,7 +260,7 @@ ltAutoGunPic it =
miniGun :: Item
miniGun = defaultAutoGun
{ _itName = "MINI-G"
, _itIdentity = MiniGun
, _itCombineType = MINIGUN
, _itConsumption = defaultAmmo
{ _aoType = basicBullet
, _ammoMax = 1500
@@ -262,6 +305,14 @@ miniGun = defaultAutoGun
& useAim . aimStance .~ TwoHandTwist
& useAim . aimZoom .~ defaultItZoom {_itZoomFac = 1.5}
, _itFloorPict = miniGunPictItem
, _itParams = BulletShooter
{ _muzVel = 1
, _rifling = 0.9
, _bore = 2
, _gunBarrels = MultiBarrel
{_brlSpread = RotatingBarrels 0.01
,_brlNum = 4}
}
, _itEquipPict = pictureWeaponAim miniGunPictItem
, _itTweaks = defaultBulletSelTweak
, _itInvSize = 4
@@ -316,7 +367,7 @@ miniGunPict spin am =
spreadGun :: Item
spreadGun = defaultGun
{ _itName = "SPREAD"
, _itIdentity = SpreadGun
, _itCombineType = SPREADGUN
, _itConsumption = defaultAmmo
{ _aoType = basicBullet
, _ammoMax = 5
@@ -335,6 +386,7 @@ spreadGun = defaultGun
]
, _itParams = BulletShooter
{ _muzVel = 0.7
, _rifling = 0.8
, _bore = 2
, _gunBarrels = MultiBarrel
{_brlNum = 5
@@ -355,7 +407,7 @@ spreadGunPic it =
multGun :: Item
multGun = defaultGun
{ _itName = "MULTGUN"
, _itIdentity = MultGun
, _itCombineType = MULTGUN
, _itConsumption = defaultAmmo
{ _aoType = basicBullet
, _ammoMax = 5
@@ -380,6 +432,7 @@ multGun = defaultGun
, _itFloorPict = multGunSPic
, _itParams = BulletShooter
{ _muzVel = 1
, _rifling = 0.9
, _bore = 3
, _gunBarrels = MultiBarrel
{_brlNum = 5
@@ -406,7 +459,7 @@ multGunSPic it =
longGun :: Item
longGun = defaultGun
{ _itName = "LONGGUN"
, _itIdentity = LongGun
, _itCombineType = LONGGUN
, _itConsumption = defaultAmmo
{ _aoType = hvBullet
, _ammoMax = 1
+1 -1
View File
@@ -21,7 +21,7 @@ import Control.Lens
lasDrones :: Item
lasDrones = defaultGun
{ _itName = "DRONES"
, _itIdentity = Generic
, _itCombineType = DRONELAUNCHER
, _itConsumption = defaultAmmo
{ _aoType = DroneAmmo { _amString = "LASDRONE" }
, _ammoMax = 2
+2 -2
View File
@@ -25,10 +25,10 @@ import Control.Lens
grenade :: Item
grenade = Throwable
{ _itName = "GRENADE " ++ show fuseTime
, _itCombineType = GRENADE
, _itInvSize = 1
, _itDimension = defaultItemDimension
, _itCurseStatus = Uncursed
, _itIdentity = Grenade
, _itMaxStack = 8
, _itAmount = 1
, _itFloorPict = \_ -> (,) emptySH $ onLayer FlItLayer $ polygon $ map toV2 [(-3,-3),(-3,3),(3,3),(3,-3)]
@@ -213,7 +213,7 @@ defaultThrowable = grenade
remoteBomb :: Item
remoteBomb = defaultThrowable
{ _itName = "REMOTEBOMB"
, _itIdentity = RemoteBomb
, _itCombineType = REMOTEBOMB
, _itMaxStack = 1
, _itAmount = 1
, _itFloorPict = \_ -> (,) emptySH $ onLayer FlItLayer $ polygon $ map toV2
@@ -23,6 +23,7 @@ basicWeaponDisplay it = [midPadL 10 ' ' thename (' ' : thenumber) ++ theparam]
Just' x -> show x ++ "R" ++ show (_ammoLoaded am)
Just am@ChargeableAmmo{} -> show $ _wpCharge am
Just x@ItemItselfConsumable{} -> show $ _itMaxStack' x
Just NoConsumption -> "NOCONSUMPTION"
Nothing -> ""
theparam = fromMaybe []
. listToMaybe
+2 -2
View File
@@ -37,7 +37,7 @@ import System.Random
launcher :: Item
launcher = defaultGun
{ _itName = "ROCKO"
, _itIdentity = Launcher
, _itCombineType = LAUNCHER
, _itConsumption = defaultAmmo
{ _aoType = defaultShellAmmo
{ _amPayload = makeExplosionAt
@@ -260,7 +260,7 @@ trySpinByCID cid i pj w = w & props . ix pjid . pjSpin .~ newSpin
remoteLauncher :: Item
remoteLauncher = defaultGun
{ _itName = "ROCKO-REM"
, _itIdentity = RemoteLauncher
, _itCombineType = LAUNCHER
, _itConsumption = defaultAmmo
{ _aoType = defaultShellAmmo
{ _amPayload = makeExplosionAt
+4 -4
View File
@@ -20,7 +20,7 @@ Sends out pulses that display walls. -}
radar :: Item
radar = defaultGun
{ _itName = "RADAR"
, _itIdentity = Generic
, _itCombineType = RADAR
, _itConsumption = defaultAmmo
{ _ammoMax = 100
, _ammoLoaded = 100
@@ -40,7 +40,7 @@ Sends out pulses that display creatures. -}
sonar :: Item
sonar = defaultGun
{ _itName = "SONAR"
, _itIdentity = Generic
, _itCombineType = RADAR
, _itConsumption = defaultAmmo
{ _ammoMax = 100
, _ammoLoaded = 100
@@ -59,7 +59,7 @@ sonar = defaultGun
Automatically sends out pulses that display creatures. -}
autoSonar :: Item
autoSonar = defaultEquipment
{ _itIdentity = Generic
{ _itCombineType = RADAR
, _itName = "AUTOSONAR"
, _itMaxStack = 1
, _itAmount = 1
@@ -73,7 +73,7 @@ autoSonar = defaultEquipment
Automatically sends out pulses that display walls. -}
autoRadar :: Item
autoRadar = defaultEquipment
{ _itIdentity = Generic
{ _itCombineType = RADAR
, _itName = "AUTORADAR"
, _itMaxStack = 1
, _itAmount = 1
+2 -2
View File
@@ -33,7 +33,7 @@ import System.Random
poisonSprayer :: Item
poisonSprayer = defaultAutoGun
{ _itName = "POISON"
, _itIdentity = PoisonSprayer
, _itCombineType = SPRAYER
, _itConsumption = defaultAmmo
{ _ammoMax = 500
, _ammoLoaded = 500
@@ -57,7 +57,7 @@ poisonSprayer = defaultAutoGun
flamer :: Item
flamer = defaultAutoGun
{ _itName = "FLAMER"
, _itIdentity = Flamethrower
, _itCombineType = SQUIRTER
, _itConsumption = defaultAmmo
{ _ammoMax = 250
, _ammoLoaded = 250
+4 -4
View File
@@ -19,7 +19,7 @@ import Control.Lens
rewindGun :: Item
rewindGun = defaultGun
{ _itName = "REWINDER"
, _itIdentity = Rewinder
, _itCombineType = REWINDER
, _itConsumption = ChargeableAmmo
{ _wpMaxCharge = 250
, _wpCharge = 0
@@ -55,7 +55,7 @@ useRewindGun _ _ w = case _rewindWorlds w of
shrinkGun :: Item
shrinkGun = defaultGun
{ _itName = "SHRINKER"
, _itIdentity = Generic
, _itCombineType = SHRINKER
, _itConsumption = defaultAmmo
{ _ammoMax = 100
, _ammoLoaded = 100
@@ -85,7 +85,7 @@ useShrinkGun cr invid w = if _itBool $ _itAttachment it
blinkGun :: Item
blinkGun = defaultGun
{ _itName = "BLINKER"
, _itIdentity = Blinker
, _itCombineType = BLINKER
, _itConsumption = defaultAmmo
{ _ammoMax = 100
, _ammoLoaded = 100
@@ -117,7 +117,7 @@ autoEffectGun name eff = defaultAutoGun
forceFieldGun :: Item
forceFieldGun = defaultGun
{ _itName = "FORCEFIELD"
, _itIdentity = ForceFieldGun
, _itCombineType = FORCEFIELD
, _itConsumption = defaultAmmo
{ _ammoMax = 100
, _ammoLoaded = 100
+6 -6
View File
@@ -13,16 +13,16 @@ import Control.Monad.State
-- (const $ return $ chainUses $ map singleUseAll [door,lasTunnel,door] , return FlatShield )
-- ,
lockRoomKeyItems :: RandomGen g => [ (Int -> State g (SubCompTree Room) , State g ItemIdentity ) ]
lockRoomKeyItems :: RandomGen g => [ (Int -> State g (SubCompTree Room) , State g CombineType ) ]
lockRoomKeyItems =
[(lasCenSensEdge, takeOne [Launcher] )
,(const slowDoorRoomRunPast, return MiniGun)
[(lasCenSensEdge, takeOne [LAUNCHER] )
,(const slowDoorRoomRunPast, return MINIGUN)
]
itemRooms :: RandomGen g => [(ItemIdentity, State g (SubCompTree Room))]
itemRooms :: RandomGen g => [(CombineType, State g (SubCompTree Room))]
itemRooms =
[ (Launcher , corridorBoss launcherCrit )
, (MiniGun , join $ takeOne [roomMiniIntro, minigunFakeout] )
[ (LAUNCHER , corridorBoss launcherCrit )
, (MINIGUN , join $ takeOne [roomMiniIntro, minigunFakeout] )
]
corridorBoss :: RandomGen g => Creature -> State g (SubCompTree Room)
+3 -3
View File
@@ -56,7 +56,7 @@ bulBounceArmCr' bt p cr w
pOut = p +.+ 2 *.* newDir
reflectVel = magV bulVel *.* newDir
addBouncer = worldEvents %~ ( over particles (bouncer :) . )
bouncer = (aGenBulAt Nothing pOut reflectVel
bouncer = (aGenBulAt Nothing pOut reflectVel (_btDrag bt)
(_btHitEffect' bt) (_btWidth' bt)
) {_btTimer' = _btTimer' bt - 1}
{- | Bullet pass through creatures. -}
@@ -79,7 +79,7 @@ bulPenCr' bt p cr w
sp = head $ _btTrail' bt
ep = sp +.+ _btVel' bt
addPiercer = over particles (piercer :)
piercer = (aGenBulAt (Just cid) p (_btVel' bt)
piercer = (aGenBulAt (Just cid) p (_btVel' bt) (_btDrag bt)
(_btHitEffect' bt) (_btWidth' bt)
) {_btTimer' = _btTimer' bt - 1}
{- | Heavy bullet effects when hitting creature:
@@ -138,7 +138,7 @@ bulBounceWall bt p wl = damageWall (Blunt 50 sp p ep) wl . over worldEvents addB
ep = sp +.+ _btVel' bt
sp = head $ _btTrail' bt
pOut = p +.+ squashNormalizeV (sp -.- p)
bouncer = (aGenBulAt Nothing pOut reflectVel (_btHitEffect' bt) (_btWidth' bt)
bouncer = (aGenBulAt Nothing pOut reflectVel 0.5 (_btHitEffect' bt) (_btWidth' bt)
) {_btTimer' = _btTimer' bt - 1}
reflectVel = reflVelWall wl (_btVel' bt)
addBouncer = ( over particles (bouncer : ) . )
+8 -3
View File
@@ -16,13 +16,15 @@ aGenBulAt
:: Maybe Int -- ^ Pass-through creature id
-> Point2 -- ^ Start position
-> Point2 -- ^ Velocity
-> Float -- ^ Slowdown
-> HitEffect
-> Float -- ^ Bullet width
-> Particle
aGenBulAt maycid pos vel hiteff width = BulletPt
aGenBulAt maycid pos vel drag hiteff width = BulletPt
{ _ptDraw = drawBul
, _ptUpdate = mvBullet
, _btVel' = vel
, _btVel' = vel
, _btDrag = drag
, _btColor' = V4 2 2 2 2
, _btTrail' = [pos]
, _btPassThrough' = maycid
@@ -35,13 +37,15 @@ aDelayedBulAt
-> Maybe Int -- ^ Pass-through creature id
-> Point2 -- ^ Start position
-> Point2 -- ^ Velocity
-> Float -- ^ Drag
-> HitEffect
-> Float -- ^ Bullet width
-> Particle
aDelayedBulAt vfact maycid pos vel hiteff width = BulletPt
aDelayedBulAt vfact maycid pos vel drag hiteff width = BulletPt
{ _ptDraw = drawBul
, _ptUpdate = \w -> resetVel . mvBullet w
, _btVel' = vfact *.* vel
, _btDrag = drag
, _btColor' = V4 2 2 2 2
, _btTrail' = [pos]
, _btPassThrough' = maycid
@@ -65,6 +69,7 @@ aCurveBulAt maycid col pos control targ hiteff width = BulletPt
{ _ptDraw = drawBul
, _ptUpdate = \w -> mvBullet w . setVel
, _btVel' = V2 0 0
, _btDrag = 1
, _btColor' = col
, _btTrail' = [pos]
, _btPassThrough' = maycid
+6 -8
View File
@@ -10,23 +10,21 @@ import Dodge.WorldEvent.ThingsHit
import Geometry
--import Geometry.Vector3D
import Data.Bifunctor
import Control.Lens
{-
Update for a generic bullet.
-}
mvBullet :: World -> Particle -> (World, Maybe Particle)
mvBullet w bt
| t <= 0 = wAnd Nothing
| t < 4 = wAnd $ Just $ bt
& btPassThrough' .~ Nothing
& btTrail' .~ (p:p:ps)
& btTimer' -~ 1
-- | otherwise = hiteff bt (thingsHitExceptCr3D' mcr (addZ 20 p) (addZ 20 (p +.+ vel)) w) w
| otherwise = hiteff bt (thingsHitExceptCr mcr p (p +.+ vel) w) w
| t <= 0 || magV (_btVel' bt) < 1 = wAnd Nothing
| otherwise = second (fmap dodrag) $ hiteff bt (thingsHitExceptCr mcr p (p +.+ vel) w) w
where
dodrag = btVel' %~ (drag *.*)
drag = _btDrag bt
wAnd = (w,)
mcr = _btPassThrough' bt
(p:ps) = _btTrail' bt
(p:_) = _btTrail' bt
vel = _btVel' bt
hiteff = _btHitEffect' bt
t = _btTimer' bt
+1
View File
@@ -25,6 +25,7 @@ colSpark' randDir time col pos baseDir w = w
spark = BulletPt
{ _ptDraw = drawBul
, _ptUpdate = mvBullet
, _btDrag = 0.9
, _btVel' = rotateV dir (V2 5 0)
, _btColor' = col
, _btTrail' = [pos]
+1
View File
@@ -35,6 +35,7 @@ createBarrelSpark pos dir maycid time colid w = w
{ _ptDraw = drawBul
, _ptUpdate = mvBullet
, _btVel' = rotateV dir (V2 5 0)
, _btDrag = 0.9
, _btColor' = numColor colid
, _btTrail' = [pos]
, _btPassThrough' = maycid
+4
View File
@@ -5,6 +5,7 @@ module ShapePicture
, rotateSP
, SPic
, noPic
, noShape
, _spShape
, _spPicture
)
@@ -20,6 +21,9 @@ type SPic = (Shape, Picture)
noPic :: Shape -> SPic
noPic sh = (sh,mempty)
noShape :: Picture -> SPic
noShape pic = (mempty,pic)
_spShape :: SPic -> Shape
_spShape = fst
_spPicture :: SPic -> Picture