Cleanup Data

This commit is contained in:
2021-03-26 23:49:07 +01:00
parent fb1d7571e7
commit 62b5ffbfaa
7 changed files with 460 additions and 455 deletions
+5 -5
View File
@@ -6,9 +6,9 @@ import Geometry
import Control.Lens import Control.Lens
-- isArmouredFrom :: Point2 -> Creature -> Bool isArmouredFrom :: Point2 -> Creature -> Bool
-- isArmouredFrom p cr isArmouredFrom p cr
-- = p /= _crPos cr = p /= _crPos cr
-- && any (\it -> it ^? itIdentity == Just FrontArmour) (_crInv cr) && any (\it -> it ^? itIdentity == Just FrontArmour) (_crInv cr)
-- && angleVV (unitVectorAtAngle $ _crDir cr) (p -.- _crPos cr) < pi/2 && angleVV (unitVectorAtAngle $ _crDir cr) (p -.- _crPos cr) < pi/2
-- even though angleVV can generate NaN, the comparison seems to deal with it -- even though angleVV can generate NaN, the comparison seems to deal with it
+3 -1
View File
@@ -350,7 +350,8 @@ startCr = defaultCreature
, _crHP = 10000 , _crHP = 10000
, _crMaxHP = 1500 , _crMaxHP = 1500
, _crInv = IM.fromList (zip [0..20] , _crInv = IM.fromList (zip [0..20]
([pistol,autoGun,launcher,lasGun,grenade (
[pistol,autoGun,launcher,lasGun,grenade
,ltAutoGun,flamer,multGun,spreadGun,remoteLauncher ,ltAutoGun,flamer,multGun,spreadGun,remoteLauncher
,longGun ,longGun
,hvAutoGun ,hvAutoGun
@@ -361,6 +362,7 @@ startCr = defaultCreature
,bezierGun ,bezierGun
,poisonSprayer ,poisonSprayer
,blinkGun ,blinkGun
,frontArmour
] ]
++ repeat NoItem)) ++ repeat NoItem))
-- startInv -- startInv
+65 -61
View File
@@ -1,6 +1,5 @@
{-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE FlexibleInstances #-}
--{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE StrictData #-} {-# LANGUAGE StrictData #-}
module Dodge.Data module Dodge.Data
( module Dodge.Data ( module Dodge.Data
@@ -9,39 +8,27 @@ module Dodge.Data
, soundTime , soundTime
) )
where where
-- imports {{{
import Picture.Data import Picture.Data
import Geometry.Data import Geometry.Data
import Sound.Preload import Sound.Preload
import Control.Lens import Control.Lens
import Control.Monad.State import Control.Monad.State
import System.Random import System.Random
import Data.Graph.Inductive import Data.Graph.Inductive
import qualified Data.Set as S import qualified Data.Set as S
import qualified Data.IntMap.Strict as IM import qualified Data.IntMap.Strict as IM
import qualified Data.Map as M import qualified Data.Map as M
import qualified SDL.Mixer as Mix import qualified SDL.Mixer as Mix
import SDL (Scancode, MouseButton) import SDL (Scancode, MouseButton)
import Graphics.Rendering.OpenGL (PrimitiveMode (..),GLfloat,Program,VertexArrayObject,BufferObject) import Graphics.Rendering.OpenGL (PrimitiveMode (..),GLfloat,Program,VertexArrayObject,BufferObject)
import Codec.Picture (Image,PixelRGBA8) import Codec.Picture (Image,PixelRGBA8)
import qualified Data.DList as DL import qualified Data.DList as DL
import LoadConfig import LoadConfig
--}}}
-- datatypes {{{
data World = World data World = World
{ _keys :: !(S.Set Scancode) { _keys :: !(S.Set Scancode)
, _mouseButtons :: !(S.Set MouseButton) , _mouseButtons :: !(S.Set MouseButton)
, _cameraCenter :: !Point2 , _cameraCenter :: !Point2
, _cameraAimTime :: Int
, _cameraRot :: !Float , _cameraRot :: !Float
, _cameraZoom :: !Float , _cameraZoom :: !Float
, _cameraViewFrom :: !Point2 , _cameraViewFrom :: !Point2
@@ -68,7 +55,6 @@ data World = World
, _decorations :: IM.IntMap Picture , _decorations :: IM.IntMap Picture
, _corpses :: IM.IntMap (IM.IntMap [Corpse]) , _corpses :: IM.IntMap (IM.IntMap [Corpse])
, _clickMousePos :: (Float,Float) , _clickMousePos :: (Float,Float)
, _lbRotation :: Float
, _pathGraph :: ~(Gr Point2 Float) , _pathGraph :: ~(Gr Point2 Float)
, _pathGraph' :: ~[(Point2,Point2)] , _pathGraph' :: ~[(Point2,Point2)]
, _pathPoints :: ~(IM.IntMap (IM.IntMap [(Int,Point2)])) , _pathPoints :: ~(IM.IntMap (IM.IntMap [(Int,Point2)]))
@@ -96,9 +82,18 @@ data Corpse = Corpse
, _cpRes :: Creature , _cpRes :: Creature
} }
data Layer = PtLayer | CrLayer | WlLayer | BgLayer | ShadowLayer data Layer
| FlItLayer | LabelLayer | InvLayer | MenuLayer = PtLayer
| PressPlateLayer | CorpseLayer | CrLayer
| WlLayer
| BgLayer
| ShadowLayer
| FlItLayer
| LabelLayer
| InvLayer
| MenuLayer
| PressPlateLayer
| CorpseLayer
| UPtLayer | UPtLayer
| HPtLayer | HPtLayer
| GloomLayer | GloomLayer
@@ -113,8 +108,7 @@ data Cloud = Cloud
, _clEffect :: Cloud -> World -> World , _clEffect :: Cloud -> World -> World
} }
data LightSource data LightSource = LS
= LS
{ _lsID :: !Int { _lsID :: !Int
, _lsPos :: !Point2 , _lsPos :: !Point2
, _lsDir :: !Float , _lsDir :: !Float
@@ -122,8 +116,8 @@ data LightSource
, _lsIntensity :: !Float , _lsIntensity :: !Float
} }
data TempLightSource = data TempLightSource = TLS
TLS { _tlsPos :: !Point2 { _tlsPos :: !Point2
, _tlsRad :: !Float , _tlsRad :: !Float
, _tlsIntensity :: !Float , _tlsIntensity :: !Float
, _tlsUpdate :: World -> TempLightSource -> (World, Maybe TempLightSource) , _tlsUpdate :: World -> TempLightSource -> (World, Maybe TempLightSource)
@@ -147,8 +141,8 @@ data Creature = Creature
, _crCorpse :: Picture , _crCorpse :: Picture
} }
data CreatureState data CreatureState = CrSt
= CrSt { _goals :: [[Goal]] { _goals :: [[Goal]]
, _stance :: Stance , _stance :: Stance
, _faction :: Faction , _faction :: Faction
, _crDamage :: [DamageType] , _crDamage :: [DamageType]
@@ -156,11 +150,13 @@ data CreatureState
, _crSpState :: CrSpState , _crSpState :: CrSpState
, _crApplyDamage :: [DamageType] -> Creature -> (World -> World,Creature) , _crApplyDamage :: [DamageType] -> Creature -> (World -> World,Creature)
} }
-- deriving (Eq,Show)
data CrSpState = Barrel { _piercedPoints :: [Point2]} data CrSpState
= Barrel { _piercedPoints :: [Point2]}
| GenCr | GenCr
deriving (Eq,Show,Ord) deriving (Eq,Show,Ord)
data Goal = MoveTo Point2 data Goal
= MoveTo Point2
| MoveToFor Point2 Int | MoveToFor Point2 Int
| MoveFire Point2 Point2 | MoveFire Point2 Point2
| PathTo Point2 | PathTo Point2
@@ -209,23 +205,22 @@ data Goal = MoveTo Point2
| MakeJudgement | MakeJudgement
| SetPosture Posture | SetPosture Posture
deriving (Eq,Show) deriving (Eq,Show)
data Stance = Stance {_carriage :: Carriage data Stance = Stance
{_carriage :: Carriage
,_posture :: Posture ,_posture :: Posture
} }
deriving (Eq,Show) deriving (Eq,Show)
data Carriage = Walking {_stepCycle :: Int data Carriage
,_stepToAdd :: Int = Walking { _stepCycle :: Int, _stepToAdd :: Int }
}
| Floating | Floating
| Boosting Point2 | Boosting Point2
deriving (Eq,Show) deriving (Eq,Show)
data Posture = Aiming data Posture = Aiming | AtEase
| AtEase
deriving (Eq,Show) deriving (Eq,Show)
data Mind = ZombieMind data Mind = ZombieMind | HumanMind
| HumanMind
deriving (Eq,Show) deriving (Eq,Show)
data Faction = GenericFaction Int data Faction
= GenericFaction Int
| ZombieFaction | ZombieFaction
| EncircleFlock | EncircleFlock
| ChaseCritters | ChaseCritters
@@ -234,9 +229,7 @@ data Faction = GenericFaction Int
deriving (Eq,Show) deriving (Eq,Show)
-- NOTE: walls must be drawn counterclockwise -- NOTE: walls must be drawn counterclockwise
data WorldState = DoorNumOpen Int | CrNumAlive Int
data WorldState = DoorNumOpen Int
| CrNumAlive Int
deriving (Eq,Ord) deriving (Eq,Ord)
data MenuState data MenuState
@@ -259,7 +252,8 @@ data Button = Button
data ButtonState = BtOn | BtOff | BtNoLabel data ButtonState = BtOn | BtOff | BtNoLabel
deriving (Eq, Show) deriving (Eq, Show)
data PressPlate = PressPlate { _ppPict :: Picture data PressPlate = PressPlate
{ _ppPict :: Picture
, _ppPos :: Point2 , _ppPos :: Point2
, _ppRot :: Float , _ppRot :: Float
, _ppEvent :: PressPlate -> World -> World , _ppEvent :: PressPlate -> World -> World
@@ -269,13 +263,12 @@ data PressPlate = PressPlate { _ppPict :: Picture
data FloorItem = FlIt { _flIt :: Item , _flItPos :: Point2 , _flItRot :: Float, _flItID :: Int} data FloorItem = FlIt { _flIt :: Item , _flItPos :: Point2 , _flItRot :: Float, _flItID :: Int}
data ItemPos = InInv { _itCrId :: Int data ItemPos
, _itInvId :: Int = InInv { _itCrId :: Int , _itInvId :: Int }
} | OnFloor { _itFlID :: Int }
| OnFloor { _itFlID :: Int
}
data Item = Weapon data Item
= Weapon
{ _itName :: String { _itName :: String
, _wpMaxAmmo :: Int , _wpMaxAmmo :: Int
, _wpLoadedAmmo :: Int , _wpLoadedAmmo :: Int
@@ -369,7 +362,8 @@ data Item = Weapon
| NoItem | NoItem
data ItAttachment data ItAttachment
= ItScope {_scopePos :: Point2 = ItScope
{_scopePos :: Point2
,_scopeZoomChange :: Int ,_scopeZoomChange :: Int
,_scopeZoom :: Float ,_scopeZoom :: Float
,_scopeIsCamera :: Bool ,_scopeIsCamera :: Bool
@@ -380,14 +374,17 @@ data ItAttachment
| ItTargetPos { _itTargetPos :: Point2 } | ItTargetPos { _itTargetPos :: Point2 }
data ItEffect = NoItEffect data ItEffect = NoItEffect
| ItInvEffect {_itInvEffect :: Creature -> Int -> World -> World | ItInvEffect
{_itInvEffect :: Creature -> Int -> World -> World
,_itEffectCounter :: Int ,_itEffectCounter :: Int
} }
| ItEffect {_itInvEffect :: Creature -> Int -> World -> World | ItEffect
{_itInvEffect :: Creature -> Int -> World -> World
,_itFloorEffect :: Int -> World -> World ,_itFloorEffect :: Int -> World -> World
,_itEffectCounter :: Int ,_itEffectCounter :: Int
} }
data ItZoom = ItZoom {_itAimZoomMax :: Float data ItZoom = ItZoom
{_itAimZoomMax :: Float
,_itAimZoomMin :: Float ,_itAimZoomMin :: Float
,_itAimZoomFac :: Float ,_itAimZoomFac :: Float
,_itZoomMax :: Float ,_itZoomMax :: Float
@@ -397,7 +394,8 @@ data ItZoom = ItZoom {_itAimZoomMax :: Float
data IntID a = IntID Int a data IntID a = IntID Int a
data HammerPosition = HammerDown data HammerPosition
= HammerDown
| HammerReleased | HammerReleased
| HammerUp | HammerUp
| NoHammer | NoHammer
@@ -439,7 +437,8 @@ data Particle'
{ _ptDraw :: Particle' -> Picture { _ptDraw :: Particle' -> Picture
, _ptUpdate' :: World -> Particle' -> (World, Maybe Particle') , _ptUpdate' :: World -> Particle' -> (World, Maybe Particle')
} }
| Bul' { _ptDraw :: Particle' -> Picture | Bul'
{ _ptDraw :: Particle' -> Picture
, _ptUpdate' :: World -> Particle' -> (World, Maybe Particle') , _ptUpdate' :: World -> Particle' -> (World, Maybe Particle')
, _btVel' :: Point2 , _btVel' :: Point2
, _btColor' :: Color , _btColor' :: Color
@@ -449,7 +448,8 @@ data Particle'
, _btTimer' :: Int , _btTimer' :: Int
, _btHitEffect' :: HitEffect , _btHitEffect' :: HitEffect
} }
| Pt' { _ptDraw :: Particle' -> Picture | Pt'
{ _ptDraw :: Particle' -> Picture
, _ptUpdate' :: World -> Particle' -> (World, Maybe Particle') , _ptUpdate' :: World -> Particle' -> (World, Maybe Particle')
, _btVel' :: Point2 , _btVel' :: Point2
, _btColor' :: Color , _btColor' :: Color
@@ -475,7 +475,8 @@ type HitEffect = Particle' -> [(Point2, (Either3 Creature Wall ForceField))] ->
-> (World,Maybe Particle') -> (World,Maybe Particle')
data Projectile = Projectile { _ptPos :: Point2 data Projectile = Projectile
{ _ptPos :: Point2
, _ptStartPos :: Point2 , _ptStartPos :: Point2
, _ptVel :: Point2 , _ptVel :: Point2
, _ptPict :: Picture , _ptPict :: Picture
@@ -483,14 +484,19 @@ data Projectile = Projectile { _ptPos :: Point2
, _ptUpdate :: World -> World , _ptUpdate :: World -> World
} }
data DamageType = Piercing {_dmAmount :: Int , _dmFrom :: Point2 , _dmAt :: Point2 , _dmTo :: Point2 } data DamageType
= Piercing {_dmAmount :: Int , _dmFrom :: Point2 , _dmAt :: Point2 , _dmTo :: Point2 }
| Blunt {_dmAmount :: Int , _dmFrom :: Point2 , _dmAt :: Point2 , _dmTo :: Point2 } | Blunt {_dmAmount :: Int , _dmFrom :: Point2 , _dmAt :: Point2 , _dmTo :: Point2 }
| SparkDam {_dmAmount :: Int , _dmFrom :: Point2 , _dmAt :: Point2 , _dmTo :: Point2 } | SparkDam {_dmAmount :: Int , _dmFrom :: Point2 , _dmAt :: Point2 , _dmTo :: Point2 }
| Flaming {_dmAmount :: Int , _dmFrom :: Point2 , _dmAt :: Point2 , _dmTo :: Point2 } | Flaming {_dmAmount :: Int , _dmFrom :: Point2 , _dmAt :: Point2 , _dmTo :: Point2 }
| Lasering {_dmAmount :: Int , _dmFrom :: Point2 , _dmAt :: Point2 , _dmTo :: Point2 } | Lasering {_dmAmount :: Int , _dmFrom :: Point2 , _dmAt :: Point2 , _dmTo :: Point2 }
| Concussive {_dmAmount :: Int , _dmFrom :: Point2 , _dmPush :: Float | Concussive
{ _dmAmount :: Int
, _dmFrom :: Point2
, _dmPush :: Float
, _dmPushExp :: Float , _dmPushExp :: Float
, _dmPushRadius :: Float} , _dmPushRadius :: Float
}
| TorqueDam {_dmAmount :: Int , _dmTorque :: Float } | TorqueDam {_dmAmount :: Int , _dmTorque :: Float }
| PushDam {_dmAmount :: Int , _dmPushBack :: Point2 } | PushDam {_dmAmount :: Int , _dmPushBack :: Point2 }
| PoisonDam {_dmAmount :: Int} | PoisonDam {_dmAmount :: Int}
@@ -542,7 +548,8 @@ data Wall
, _blShadows :: [Int] , _blShadows :: [Int]
} }
data ForceField = FF { _ffLine :: [Point2] , _ffID :: Int data ForceField = FF
{ _ffLine :: [Point2] , _ffID :: Int
, _ffColor :: Color , _ffColor :: Color
, _ffDeflect :: Maybe (StdGen -> Point2 -> ForceField -> (Point2,StdGen)) , _ffDeflect :: Maybe (StdGen -> Point2 -> ForceField -> (Point2,StdGen))
, _ffState :: FFState , _ffState :: FFState
@@ -587,8 +594,7 @@ data PSType = PutCrit Creature
, _collectiveFunction :: [Int] -> State StdGen [PSType] , _collectiveFunction :: [Int] -> State StdGen [PSType]
} }
| LabelPS { _psLabel :: Int, _ps :: PSType} | LabelPS { _psLabel :: Int, _ps :: PSType}
| PutWindow { _pwPoly :: [Point2] | PutWindow { _pwPoly :: [Point2] , _pwColor :: Color
, _pwColor :: Color
} }
data PlacementSpot = PS data PlacementSpot = PS
{ _psPos :: Point2 { _psPos :: Point2
@@ -635,8 +641,6 @@ makeLenses ''Button
makeLenses ''PSType makeLenses ''PSType
makeLenses ''PlacementSpot makeLenses ''PlacementSpot
makeLenses ''Room makeLenses ''Room
--
-- }}}
numColor :: Int -> Color numColor :: Int -> Color
numColor 0 = (1,0,0,1) numColor 0 = (1,0,0,1)
-2
View File
@@ -182,7 +182,6 @@ defaultWorld = World
{ _keys = S.empty { _keys = S.empty
, _mouseButtons = S.empty , _mouseButtons = S.empty
, _cameraCenter = (0,0) , _cameraCenter = (0,0)
, _cameraAimTime = 0
, _cameraRot = 0 , _cameraRot = 0
, _cameraZoom = 1 , _cameraZoom = 1
, _cameraViewFrom = (0,0) , _cameraViewFrom = (0,0)
@@ -212,7 +211,6 @@ defaultWorld = World
, _menuState = LevelMenu 1 , _menuState = LevelMenu 1
, _worldState = M.empty , _worldState = M.empty
, _clickMousePos = (0,0) , _clickMousePos = (0,0)
, _lbRotation = 0
, _pathGraph = Data.Graph.Inductive.Graph.empty , _pathGraph = Data.Graph.Inductive.Graph.empty
, _pathGraph' = [] , _pathGraph' = []
, _pathPoints = IM.empty , _pathPoints = IM.empty
+2 -1
View File
@@ -469,7 +469,8 @@ miniGun = defaultAutoGun
. withRandomDir 0.1 . withRandomDir 0.1
. withRandomOffset 9 . withRandomOffset 9
. withMuzFlare . withMuzFlare
$ withVelWthHiteff (30,0) 2 bulletEffect' . withVelWthHiteff (30,0) 2
$ destroyOnImpact bulBounceArmCr' bulHitWall' bulHitFF'
, _wpSpread = autogunSpread , _wpSpread = autogunSpread
, _wpRange = 20 , _wpRange = 20
, _itFloorPict = onLayer FlItLayer $ color red $ polygon $ rectNESW 9 5 (-9) (-5) , _itFloorPict = onLayer FlItLayer $ color red $ polygon $ rectNESW 9 5 (-9) (-5)
+42 -35
View File
@@ -6,6 +6,8 @@ import Dodge.WorldEvent
import Dodge.SoundLogic import Dodge.SoundLogic
import Dodge.RandomHelp import Dodge.RandomHelp
import Dodge.Creature.LookupStatus
import Geometry import Geometry
import System.Random import System.Random
@@ -19,42 +21,49 @@ import Picture
-- bullet effects -- bullet effects
bulHitCr' :: Particle' -> Point2 -> Creature -> World -> World bulHitCr' :: Particle' -> Point2 -> Creature -> World -> World
bulHitCr' bt p cr w = bulHitCr' bt p cr w
let sp = head $ _btTrail' bt | isArmouredFrom p cr
ep = sp +.+ _btVel' bt = createSpark 8 colID p1 (argV (p1 -.- p) + d1) Nothing
. addDamageArmoured $ w
| otherwise
= addDamage . hitSound . flashEff $ w
where
sp = head $ _btTrail' bt
bulVel = _btVel' bt
ep = sp +.+ bulVel
mvDams = [ PushDam 1 $ 2 *.* bulVel ] mvDams = [ PushDam 1 $ 2 *.* bulVel ]
addDamage = over (creatures . ix cid . crState . crDamage) addDamage = creatures . ix cid . crState . crDamage %~ ((Piercing 100 sp p ep : mvDams) ++ )
(\dams -> (Piercing 100 sp p ep : mvDams) ++ dams) addDamageArmoured = creatures . ix cid . crState . crDamage %~ (mvDams ++)
addDamageArmoured = over (creatures . ix cid . crState . crDamage)
(\dams -> mvDams ++ dams)
hitSound = soundMultiFrom [CrHitSound 0] 15 10 0 hitSound = soundMultiFrom [CrHitSound 0] 15 10 0
flashEff = over worldEvents ((.) $ bloodFlashAt p) flashEff = over worldEvents ((.) $ bloodFlashAt p)
bulVel = _btVel' bt
ck cid = (+.+) (crKnockBack cid *.* bulVel)
crKnockBack cid = (/) 1 $ (+) 2 $ _crMass $ _creatures w IM.! cid
hasArmour cr = any (\it -> it ^? itIdentity == Just FrontArmour) $ _crInv cr
cid = _crID cr cid = _crID cr
(d1,g) = randomR (-0.7,0.7) $ _randGen w (d1,g) = randomR (-0.7,0.7) $ _randGen w
(colID,_) = randomR (0,11) $ _randGen w (colID,_) = randomR (0,11) $ _randGen w
hitEffect = addDamage p1 = p +.+ 2 *.* safeNormalizeV (p -.- _crPos cr)
. hitSound
. flashEff bulBounceArmCr' :: Particle' -> Point2 -> Creature -> World -> World
$ w bulBounceArmCr' bt p cr w
in case hasArmour cr of --shit this is ugly, to refactor | isArmouredFrom p cr
True -> if hitBack = addBouncer . addDamageArmoured $ w
then hitEffect | otherwise
else createSpark 8 colID p1 = addDamage . hitSound . flashEff $ w
(argV (p -.- _crPos (_creatures w IM.! cid)) + d1) where
Nothing sp = head $ _btTrail' bt
. addDamageArmoured bulVel = _btVel' bt
$ w ep = sp +.+ bulVel
where cpos = _crPos $ _creatures w IM.! cid mvDams = [ PushDam 1 $ 2 *.* bulVel ]
relHitPos = p -.- cpos addDamage = creatures . ix cid . crState . crDamage %~ ((Piercing 100 sp p ep : mvDams) ++ )
hitBack = errorAngleVV 19 (unitVectorAtAngle (_crDir $ _creatures w IM.! cid)) addDamageArmoured = creatures . ix cid . crState . crDamage %~ (mvDams ++)
relHitPos hitSound = soundMultiFrom [CrHitSound 0] 15 10 0
> pi/2 flashEff = over worldEvents ((.) $ bloodFlashAt p)
p1 = p +.+ 2 *.* safeNormalizeV relHitPos cid = _crID cr
_ -> hitEffect newDir = safeNormalizeV (p -.- _crPos cr)
pOut = p +.+ 2 *.* newDir
reflectVel = magV bulVel *.* newDir
addBouncer = worldEvents %~ ((over particles' (bouncer :) ) . )
bouncer = (aGenBulAt' Nothing (_btColor' bt) pOut reflectVel
(_btHitEffect' bt) (_btWidth' bt)
) {_btTimer' = _btTimer' bt - 1}
bulPenCr' :: Particle' -> Point2 -> Creature -> World -> World bulPenCr' :: Particle' -> Point2 -> Creature -> World -> World
bulPenCr' bt p cr w bulPenCr' bt p cr w
@@ -142,11 +151,9 @@ bulHitWall' bt p x w = damageBlocks x
_ -> w _ -> w
bulBounceWall' :: Particle' -> Point2 -> Wall -> World -> World bulBounceWall' :: Particle' -> Point2 -> Wall -> World -> World
bulBounceWall' bt p wl w = damageBlocks wl bulBounceWall' bt p wl w = damageBlocks wl $ over worldEvents addBouncer w
$ over worldEvents addBouncer where
-- yay for hack -- should have used this before? or never? sp = head $ _btTrail' bt
w
where sp = head $ _btTrail' bt
pOut = p +.+ safeNormalizeV (sp -.- p) pOut = p +.+ safeNormalizeV (sp -.- p)
damageBlocks wall w damageBlocks wall w
= case wall ^? blHP of = case wall ^? blHP of
+1 -8
View File
@@ -17,20 +17,13 @@ import qualified SDL as SDL
import LoadConfig import LoadConfig
updateCamera :: World -> World updateCamera :: World -> World
updateCamera = rotCam . moveCamera . updateAimTime . updateScopeZoom updateCamera = rotCam . moveCamera . updateScopeZoom
updateAimTime :: World -> World
updateAimTime w
| SDL.ButtonRight `S.member` _mouseButtons w
= w & cameraAimTime %~ \t -> min (t+1) 10
| otherwise = w & cameraAimTime %~ \t -> max (t-1) 0
moveCamera :: World -> World moveCamera :: World -> World
moveCamera w = w & cameraCenter .~ idealPos moveCamera w = w & cameraCenter .~ idealPos
& cameraViewFrom .~ sightFrom & cameraViewFrom .~ sightFrom
where aimRangeFactor | _cameraZoom w == 0 = 0 where aimRangeFactor | _cameraZoom w == 0 = 0
| otherwise = (fromMaybe 0 $ yourItem w ^? itAimingRange) / _cameraZoom w | otherwise = (fromMaybe 0 $ yourItem w ^? itAimingRange) / _cameraZoom w
aimTimeFactor = fromIntegral (w ^. cameraAimTime) / 10
aimingMult | SDL.ButtonRight `S.member` _mouseButtons w = 1 aimingMult | SDL.ButtonRight `S.member` _mouseButtons w = 1
| otherwise = 0 | otherwise = 0
ypos = _crPos $ you w ypos = _crPos $ you w