Broken commit (removed loadKeyConfig)
This commit is contained in:
@@ -74,6 +74,11 @@ executables:
|
|||||||
- -funfolding-keeness-factor1000
|
- -funfolding-keeness-factor1000
|
||||||
- -fllvm
|
- -fllvm
|
||||||
- -optlo-O3
|
- -optlo-O3
|
||||||
|
- -Wall
|
||||||
|
#- -Wincomplete-uni-patterns
|
||||||
|
- -Widentities
|
||||||
|
- -Wredundant-constraints
|
||||||
|
# - -Wmissing-export-lists
|
||||||
# - -fwrite-ide-info
|
# - -fwrite-ide-info
|
||||||
# - -hiedir=.hie
|
# - -hiedir=.hie
|
||||||
dependencies:
|
dependencies:
|
||||||
|
|||||||
+26
-24
@@ -1,35 +1,37 @@
|
|||||||
module Dodge.Combine
|
module Dodge.Combine
|
||||||
|
(
|
||||||
|
)
|
||||||
where
|
where
|
||||||
--import Dodge.Data
|
--import Dodge.Data
|
||||||
import Dodge.Combine.Data
|
--import Dodge.Combine.Data
|
||||||
|
|
||||||
--import qualified Data.IntMap.Strict as IM
|
--import qualified Data.IntMap.Strict as IM
|
||||||
--import qualified Data.IntSet as IS
|
--import qualified Data.IntSet as IS
|
||||||
import qualified Data.Map.Strict as M
|
--import qualified Data.Map.Strict as M
|
||||||
|
|
||||||
--combineList :: IM.IntMap Item -> [(Item , IS.IntSet)]
|
--combineList :: IM.IntMap Item -> [(Item , IS.IntSet)]
|
||||||
--combineList
|
--combineList
|
||||||
|
|
||||||
|
|
||||||
invert :: (Ord a) => M.Map b a -> M.Map a [b]
|
--invert :: (Ord a) => M.Map b a -> M.Map a [b]
|
||||||
invert = M.foldrWithKey (\k val -> M.insertWith (++) val [k]) M.empty
|
--invert = M.foldrWithKey (\k val -> M.insertWith (++) val [k]) M.empty
|
||||||
|
--
|
||||||
combineList :: [([ItemType], ItemType)]
|
--combineList :: [([ItemType], ItemType)]
|
||||||
combineList =
|
--combineList =
|
||||||
[ ( [ TPistol, TPipe, THardware ] , TRifle )
|
-- [ ( [ TPistol, TPipe, THardware ] , TRifle )
|
||||||
, ( [ TRifle, THardware ] , TPistol )
|
-- , ( [ TRifle, THardware ] , TPistol )
|
||||||
, ( [ TPistol, TPistol, THardware ] , TSpreadGun 2 )
|
-- , ( [ TPistol, TPistol, THardware ] , TSpreadGun 2 )
|
||||||
, ( [ TSpreadGun 2, TPistol, THardware ] , TSpreadGun 3 )
|
-- , ( [ TSpreadGun 2, TPistol, THardware ] , TSpreadGun 3 )
|
||||||
, ( [ TSpreadGun 3, TPistol, THardware ] , TSpreadGun 4 )
|
-- , ( [ TSpreadGun 3, TPistol, THardware ] , TSpreadGun 4 )
|
||||||
, ( [ TSpreadGun 4, TPistol, THardware ] , TSpreadGun 5 )
|
-- , ( [ TSpreadGun 4, TPistol, THardware ] , TSpreadGun 5 )
|
||||||
, ( [ TPistol, TAutoGun, THardware ] , TLtAutoGun )
|
-- , ( [ TPistol, TAutoGun, THardware ] , TLtAutoGun )
|
||||||
, ( [ TLtAutoGun, TPipe, THardware ] , TAutoGun )
|
-- , ( [ TLtAutoGun, TPipe, THardware ] , TAutoGun )
|
||||||
, ( [ TRifle, TRifle, THardware ] , TMultGun 2 )
|
-- , ( [ TRifle, TRifle, THardware ] , TMultGun 2 )
|
||||||
, ( [ TMultGun 2, TRifle, THardware ] , TMultGun 3 )
|
-- , ( [ TMultGun 2, TRifle, THardware ] , TMultGun 3 )
|
||||||
, ( [ TMultGun 3, TRifle, THardware ] , TMultGun 4 )
|
-- , ( [ TMultGun 3, TRifle, THardware ] , TMultGun 4 )
|
||||||
, ( [ TMultGun 4, TRifle, THardware ] , TMultGun 5 )
|
-- , ( [ TMultGun 4, TRifle, THardware ] , TMultGun 5 )
|
||||||
, ( [ TLtAutoGun, TPipe, THardware ] , TAutoGun )
|
-- , ( [ TLtAutoGun, TPipe, THardware ] , TAutoGun )
|
||||||
, ( [ TPistol, TBigTube, THardware] , TLauncher 1 )
|
-- , ( [ TPistol, TBigTube, THardware] , TLauncher 1 )
|
||||||
, ( [ TLauncher 1, TBigTube, TPistol, THardware] , TLauncher 2)
|
-- , ( [ TLauncher 1, TBigTube, TPistol, THardware] , TLauncher 2)
|
||||||
, ( [ TLauncher 2, TBigTube, TPistol, THardware] , TLauncher 3)
|
-- , ( [ TLauncher 2, TBigTube, TPistol, THardware] , TLauncher 3)
|
||||||
]
|
-- ]
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
module Dodge.Combine.Data
|
module Dodge.Combine.Data
|
||||||
|
(ItemType (..)
|
||||||
|
)
|
||||||
where
|
where
|
||||||
data ItemType
|
data ItemType
|
||||||
= TPipe
|
= TPipe
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
{-# LANGUAGE DeriveGeneric #-}
|
{-# LANGUAGE DeriveGeneric #-}
|
||||||
--{-# LANGUAGE OverloadedStrings #-}
|
--{-# LANGUAGE OverloadedStrings #-}
|
||||||
module Dodge.Config.KeyConfig
|
module Dodge.Config.KeyConfig
|
||||||
|
( KeyConfigSDL (..)
|
||||||
|
, defaultKeyConfigSDL
|
||||||
|
)
|
||||||
where
|
where
|
||||||
--import Data.Aeson
|
--import Data.Aeson
|
||||||
--import Foreign.C.Types
|
--import Foreign.C.Types
|
||||||
@@ -10,26 +13,6 @@ import qualified SDL
|
|||||||
--import qualified SDL.Internal.Numbered
|
--import qualified SDL.Internal.Numbered
|
||||||
--import System.Directory
|
--import System.Directory
|
||||||
|
|
||||||
data KeyConfig = KeyConfig
|
|
||||||
{ moveUpBinding :: Int,
|
|
||||||
moveDownBinding :: Int,
|
|
||||||
moveLeftBinding :: Int,
|
|
||||||
moveRightBinding :: Int,
|
|
||||||
pauseBinding :: Int,
|
|
||||||
escapeBinding :: Int,
|
|
||||||
dropItemBinding :: Int,
|
|
||||||
toggleMapBinding :: Int,
|
|
||||||
reloadBinding :: Int,
|
|
||||||
testEventBinding :: Int,
|
|
||||||
spaceActionBinding :: Int,
|
|
||||||
rotateCameraPlusBinding :: Int,
|
|
||||||
rotateCameraMinusBinding :: Int,
|
|
||||||
zoomInBinding :: Int,
|
|
||||||
zoomOutBinding :: Int,
|
|
||||||
newBinding :: Int
|
|
||||||
}
|
|
||||||
deriving (Generic, Show)
|
|
||||||
|
|
||||||
data KeyConfigSDL = KeyConfigSDL
|
data KeyConfigSDL = KeyConfigSDL
|
||||||
{ moveUpKey :: SDL.Scancode
|
{ moveUpKey :: SDL.Scancode
|
||||||
, moveDownKey :: SDL.Scancode
|
, moveDownKey :: SDL.Scancode
|
||||||
@@ -72,86 +55,3 @@ defaultKeyConfigSDL =
|
|||||||
, newMapKey = SDL.ScancodeN
|
, newMapKey = SDL.ScancodeN
|
||||||
, modifierKey = SDL.ScancodeCapsLock
|
, modifierKey = SDL.ScancodeCapsLock
|
||||||
}
|
}
|
||||||
|
|
||||||
--instance ToJSON KeyConfig where
|
|
||||||
-- toEncoding = genericToEncoding defaultOptions
|
|
||||||
--
|
|
||||||
--instance FromJSON KeyConfig where
|
|
||||||
-- parseJSON = withObject "KeyConfig" $ \o -> do
|
|
||||||
-- moveUpBinding <- o .:? "moveUp" .!= 119
|
|
||||||
-- moveDownBinding <- o .:? "moveDown" .!= 115
|
|
||||||
-- moveLeftBinding <- o .:? "moveLeft" .!= 97
|
|
||||||
-- moveRightBinding <- o .:? "moveRight" .!= 100
|
|
||||||
-- pauseBinding <- o .:? "pause" .!= 112
|
|
||||||
-- escapeBinding <- o .:? "escape" .!= 27
|
|
||||||
-- dropItemBinding <- o .:? "dropItem" .!= 102
|
|
||||||
-- toggleMapBinding <- o .:? "toggleMap" .!= 109
|
|
||||||
-- reloadBinding <- o .:? "reload" .!= 114
|
|
||||||
-- testEventBinding <- o .:? "testEvent" .!= 116
|
|
||||||
-- spaceActionBinding <- o .:? "spaceAction" .!= 32
|
|
||||||
-- rotateCameraPlusBinding <- o .:? "rotateCameraPlus" .!= 113
|
|
||||||
-- rotateCameraMinusBinding <- o .:? "rotateCameraMinus" .!= 101
|
|
||||||
-- zoomInBinding <- o .:? "zoomIn" .!= 106
|
|
||||||
-- zoomOutBinding <- o .:? "zoomOut" .!= 107
|
|
||||||
-- newBinding <- o .:? "new" .!= 110
|
|
||||||
-- return
|
|
||||||
-- KeyConfig
|
|
||||||
-- { moveUpBinding = moveUpBinding,
|
|
||||||
-- moveDownBinding = moveDownBinding,
|
|
||||||
-- moveLeftBinding = moveLeftBinding,
|
|
||||||
-- moveRightBinding = moveRightBinding,
|
|
||||||
-- pauseBinding = pauseBinding,
|
|
||||||
-- escapeBinding = escapeBinding,
|
|
||||||
-- dropItemBinding = dropItemBinding,
|
|
||||||
-- toggleMapBinding = toggleMapBinding,
|
|
||||||
-- reloadBinding = reloadBinding,
|
|
||||||
-- testEventBinding = testEventBinding,
|
|
||||||
-- spaceActionBinding = spaceActionBinding,
|
|
||||||
-- rotateCameraPlusBinding = rotateCameraPlusBinding,
|
|
||||||
-- rotateCameraMinusBinding = rotateCameraMinusBinding,
|
|
||||||
-- zoomInBinding = zoomInBinding,
|
|
||||||
-- zoomOutBinding = zoomOutBinding,
|
|
||||||
-- newBinding = newBinding
|
|
||||||
-- }
|
|
||||||
|
|
||||||
loadKeyConfig :: IO KeyConfigSDL
|
|
||||||
loadKeyConfig = return defaultKeyConfigSDL
|
|
||||||
|
|
||||||
--loadKeyConfig' :: IO KeyConfigSDL
|
|
||||||
--loadKeyConfig' = do
|
|
||||||
-- fExists <- doesFileExist "keys.json"
|
|
||||||
-- if fExists
|
|
||||||
-- then do
|
|
||||||
-- mayConfig <- decodeFileStrict "keys.json"
|
|
||||||
-- print mayConfig
|
|
||||||
-- case mayConfig of
|
|
||||||
-- Just config ->
|
|
||||||
-- return
|
|
||||||
-- KeyConfigSDL
|
|
||||||
-- { moveUpKey = getSdlScancode $ moveUpBinding config,
|
|
||||||
-- moveDownKey = getSdlScancode $ moveDownBinding config,
|
|
||||||
-- moveLeftKey = getSdlScancode $ moveLeftBinding config,
|
|
||||||
-- moveRightKey = getSdlScancode $ moveRightBinding config,
|
|
||||||
-- pauseKey = getSdlScancode $ pauseBinding config,
|
|
||||||
-- escapeKey = getSdlScancode $ escapeBinding config,
|
|
||||||
-- dropItemKey = getSdlScancode $ dropItemBinding config,
|
|
||||||
-- toggleMapKey = getSdlScancode $ toggleMapBinding config,
|
|
||||||
-- reloadKey = getSdlScancode $ reloadBinding config,
|
|
||||||
-- testEventKey = getSdlScancode $ testEventBinding config,
|
|
||||||
-- spaceActionKey = getSdlScancode $ spaceActionBinding config,
|
|
||||||
-- rotateCameraPlusKey = getSdlScancode $ rotateCameraPlusBinding config,
|
|
||||||
-- rotateCameraMinusKey = getSdlScancode $ rotateCameraMinusBinding config,
|
|
||||||
-- zoomInKey = getSdlScancode $ zoomInBinding config,
|
|
||||||
-- zoomOutKey = getSdlScancode $ zoomOutBinding config,
|
|
||||||
-- newKey = getSdlScancode $ newBinding config
|
|
||||||
-- }
|
|
||||||
-- Nothing -> do
|
|
||||||
-- putStrLn "invalid keys.json, loading default config"
|
|
||||||
-- -- This is duplicated but not sure how to reduce
|
|
||||||
-- return defaultKeyConfigSDL
|
|
||||||
-- else do
|
|
||||||
-- putStrLn "No keys.json found, loading default config"
|
|
||||||
-- return defaultKeyConfigSDL
|
|
||||||
--
|
|
||||||
--getSdlScancode :: Int -> SDL.Scancode
|
|
||||||
--getSdlScancode x = SDL.Internal.Numbered.fromNumber (fromIntegral x) :: SDL.Scancode
|
|
||||||
|
|||||||
@@ -1,7 +1,13 @@
|
|||||||
{-# LANGUAGE TemplateHaskell #-}
|
{-# LANGUAGE TemplateHaskell #-}
|
||||||
{-# LANGUAGE StrictData #-}
|
{-# LANGUAGE StrictData #-}
|
||||||
module Dodge.Creature.AlertLevel.Data
|
module Dodge.Creature.AlertLevel.Data
|
||||||
where
|
( AwakeLevel (..)
|
||||||
|
, AttentionDir (..)
|
||||||
|
, AwarenessLevel (..)
|
||||||
|
-- lenses
|
||||||
|
, getAttentiveTo
|
||||||
|
, getFixated
|
||||||
|
) where
|
||||||
import Control.Lens
|
import Control.Lens
|
||||||
|
|
||||||
data AwakeLevel
|
data AwakeLevel
|
||||||
@@ -12,8 +18,8 @@ data AwakeLevel
|
|||||||
| Overstrung
|
| Overstrung
|
||||||
|
|
||||||
data AttentionDir
|
data AttentionDir
|
||||||
= AttentiveTo {_unAttentiveTo :: [Int]}
|
= AttentiveTo {_getAttentiveTo :: [Int]}
|
||||||
| Fixated {_unFixated :: Int }
|
| Fixated {_getFixated :: Int }
|
||||||
|
|
||||||
data AwarenessLevel
|
data AwarenessLevel
|
||||||
= AwarenessInt Int
|
= AwarenessInt Int
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ followImpulse cr w imp = case imp of
|
|||||||
posFromID cid = _crPos $ _creatures w IM.! cid
|
posFromID cid = _crPos $ _creatures w IM.! cid
|
||||||
rr a = fst $ randomR (-a,a) $ _randGen w
|
rr a = fst $ randomR (-a,a) $ _randGen w
|
||||||
hitCr i = over (creatures . ix i . crState . crDamage) (addDam i)
|
hitCr i = over (creatures . ix i . crState . crDamage) (addDam i)
|
||||||
. soundOnce (fromIntegral hitSound)
|
. soundOnce hitSound
|
||||||
addDam i dams = Blunt 100 cpos (posFromID i) (posFromID i) : dams
|
addDam i dams = Blunt 100 cpos (posFromID i) (posFromID i) : dams
|
||||||
|
|
||||||
actionUpdateAI
|
actionUpdateAI
|
||||||
|
|||||||
+7
-3
@@ -1,12 +1,16 @@
|
|||||||
module Dodge.Graph
|
module Dodge.Graph
|
||||||
where
|
( pairsToSCC
|
||||||
|
, incidenceToFunction
|
||||||
|
, pairsToIncidence
|
||||||
|
) where
|
||||||
|
-- this deserves tests
|
||||||
import Data.List.Extra
|
import Data.List.Extra
|
||||||
|
|
||||||
import Data.Bifunctor (first)
|
import Data.Bifunctor (first)
|
||||||
import Data.Graph
|
import Data.Graph
|
||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
|
|
||||||
pairsToIncidence :: (Eq a,Ord a) => [(a,a)] -> [(a,[a])]
|
pairsToIncidence :: Ord a => [(a,a)] -> [(a,[a])]
|
||||||
pairsToIncidence
|
pairsToIncidence
|
||||||
= map (first head . unzip)
|
= map (first head . unzip)
|
||||||
. groupOn fst
|
. groupOn fst
|
||||||
@@ -18,5 +22,5 @@ incidenceToFunction xs a = fromMaybe [] $ lookup a xs
|
|||||||
mkNode :: (a,[a]) -> (a,a,[a])
|
mkNode :: (a,[a]) -> (a,a,[a])
|
||||||
mkNode (x,xs) = (x,x,xs)
|
mkNode (x,xs) = (x,x,xs)
|
||||||
|
|
||||||
pairsToSCC :: (Eq a, Ord a) => [(a,a)] -> [SCC a]
|
pairsToSCC :: Ord a => [(a,a)] -> [SCC a]
|
||||||
pairsToSCC = stronglyConnComp . map mkNode . pairsToIncidence
|
pairsToSCC = stronglyConnComp . map mkNode . pairsToIncidence
|
||||||
|
|||||||
+17
-14
@@ -275,7 +275,7 @@ hvAutoGun = defaultAutoGun
|
|||||||
, _wpAmmo = hvBullet
|
, _wpAmmo = hvBullet
|
||||||
}
|
}
|
||||||
where
|
where
|
||||||
mkHvBul it = withSound (fromIntegral longGunSound)
|
mkHvBul it = withSound longGunSound
|
||||||
. withThinSmoke
|
. withThinSmoke
|
||||||
. withMuzFlare
|
. withMuzFlare
|
||||||
$ useAmmoParams it
|
$ useAmmoParams it
|
||||||
@@ -322,21 +322,24 @@ miniGun = defaultAutoGun
|
|||||||
, _wpReloadTime = 200
|
, _wpReloadTime = 200
|
||||||
, _wpReloadState = 0
|
, _wpReloadState = 0
|
||||||
, _wpMaxWarmUp = 100
|
, _wpMaxWarmUp = 100
|
||||||
, _itUseRate = 2
|
, _itUseRate = 1
|
||||||
, _itUseTime = 0
|
, _itUseTime = 0
|
||||||
, _itUse = \_ -> withWarmUp 50
|
, _itUse = \it -> withWarmUp 26
|
||||||
. shootWithSoundFor 28 2
|
. shootWithSoundFor 28 2
|
||||||
. torqueBefore 0.03 . withSidePush 50 . withRecoil 15
|
. torqueBefore 0.1
|
||||||
. withRandomDir 0.1
|
-- . torqueBefore 0.03
|
||||||
|
. withSidePush 50
|
||||||
|
. withRecoil 15
|
||||||
|
-- . withRandomDir 0.1
|
||||||
. withRandomOffset 9
|
. withRandomOffset 9
|
||||||
. withMuzFlare
|
. withMuzFlare
|
||||||
. withVelWthHiteff (V2 30 0) 2
|
$ useAmmoParams it
|
||||||
$ destroyOnImpact bulBounceArmCr' bulHitWall' bulHitFF'
|
|
||||||
, _wpRange = 20
|
, _wpRange = 20
|
||||||
, _itFloorPict = onLayer FlItLayer miniGunPict
|
, _itFloorPict = onLayer FlItLayer miniGunPict
|
||||||
, _itAimingSpeed = 0.4
|
, _itAimingSpeed = 0.4
|
||||||
, _itAimingRange = 1
|
, _itAimingRange = 1
|
||||||
, _itEquipPict = pictureWeaponOnAim miniGunPict
|
, _itEquipPict = pictureWeaponOnAim miniGunPict
|
||||||
|
, _wpAmmo = basicBullet
|
||||||
}
|
}
|
||||||
miniGunPict :: Picture
|
miniGunPict :: Picture
|
||||||
miniGunPict = pictures
|
miniGunPict = pictures
|
||||||
@@ -354,7 +357,7 @@ spreadGun = defaultGun
|
|||||||
, _wpReloadState = 0
|
, _wpReloadState = 0
|
||||||
, _itUseRate = 20
|
, _itUseRate = 20
|
||||||
, _itUseTime = 0
|
, _itUseTime = 0
|
||||||
, _itUse = \_ -> shootWithSound (fromIntegral shotgunSound)
|
, _itUse = \_ -> shootWithSound shotgunSound
|
||||||
. withRecoil 100
|
. withRecoil 100
|
||||||
. withMuzFlare
|
. withMuzFlare
|
||||||
$ spreadNumVelWthHiteff spreadGunSpread 9 (V2 30 0) 2 basicBulletEffect
|
$ spreadNumVelWthHiteff spreadGunSpread 9 (V2 30 0) 2 basicBulletEffect
|
||||||
@@ -375,7 +378,7 @@ multGun = defaultGun
|
|||||||
, _wpReloadState = 0
|
, _wpReloadState = 0
|
||||||
, _itUseRate = 20
|
, _itUseRate = 20
|
||||||
, _itUseTime = 0
|
, _itUseTime = 0
|
||||||
, _itUse = \_ -> shootWithSound (fromIntegral shotgunSound)
|
, _itUse = \_ -> shootWithSound shotgunSound
|
||||||
. withRecoil 200
|
. withRecoil 200
|
||||||
. withMuzFlare
|
. withMuzFlare
|
||||||
$ numVelWthHitEff 5 (V2 50 0) 5 basicBulletEffect
|
$ numVelWthHitEff 5 (V2 50 0) 5 basicBulletEffect
|
||||||
@@ -411,7 +414,7 @@ longGun = defaultGun
|
|||||||
, _wpReloadType = PassiveReload skwareFadeTwoSecSound
|
, _wpReloadType = PassiveReload skwareFadeTwoSecSound
|
||||||
, _itUseRate = 100
|
, _itUseRate = 100
|
||||||
, _itUseTime = 0
|
, _itUseTime = 0
|
||||||
, _itUse = shootWithSound (fromIntegral longGunSound)
|
, _itUse = shootWithSound longGunSound
|
||||||
. withThickSmoke
|
. withThickSmoke
|
||||||
. torqueAfter 0.05
|
. torqueAfter 0.05
|
||||||
. withMuzFlare
|
. withMuzFlare
|
||||||
@@ -640,10 +643,10 @@ moveRemoteBomb itid time pID w
|
|||||||
$ set (projectiles .ix pID.pjUpdate) (\_ -> moveRemoteBomb itid (f time) pID)
|
$ set (projectiles .ix pID.pjUpdate) (\_ -> moveRemoteBomb itid (f time) pID)
|
||||||
w
|
w
|
||||||
| time < 2 = case hitWl of
|
| time < 2 = case hitWl of
|
||||||
Just _ -> soundOnce (fromIntegral tapQuiet) $ halfV updatedWorld
|
Just _ -> soundOnce tapQuiet $ halfV updatedWorld
|
||||||
_ -> halfV updatedWorld
|
_ -> halfV updatedWorld
|
||||||
| otherwise = case hitWl of
|
| otherwise = case hitWl of
|
||||||
Just _ -> soundOnce (fromIntegral tapQuiet) updatedWorld
|
Just _ -> soundOnce tapQuiet updatedWorld
|
||||||
_ -> updatedWorld
|
_ -> updatedWorld
|
||||||
where
|
where
|
||||||
updatedWorld
|
updatedWorld
|
||||||
@@ -757,7 +760,7 @@ fireRemoteLauncher :: Creature -> World -> World
|
|||||||
fireRemoteLauncher cr w = setLocation
|
fireRemoteLauncher cr w = setLocation
|
||||||
$ resetFire
|
$ resetFire
|
||||||
$ resetName
|
$ resetName
|
||||||
$ soundOnce (fromIntegral launcherSound)
|
$ soundOnce launcherSound
|
||||||
$ over projectiles remRocket w
|
$ over projectiles remRocket w
|
||||||
where
|
where
|
||||||
i = IM.newKey $ _projectiles w
|
i = IM.newKey $ _projectiles w
|
||||||
@@ -805,7 +808,7 @@ moveRemoteShell cid itid pj w
|
|||||||
( ( pjVel %~ ( (accel +.+) . (frict *.*) ) )
|
( ( pjVel %~ ( (accel +.+) . (frict *.*) ) )
|
||||||
. ( pjDir .~ newdir )
|
. ( pjDir .~ newdir )
|
||||||
)
|
)
|
||||||
& soundFromPos (ShellSound i) newPos (fromIntegral smokeTrailSound) 1 250
|
& soundFromPos (ShellSound i) newPos smokeTrailSound 1 250
|
||||||
& smokeGen
|
& smokeGen
|
||||||
& makeFlameletTimed oldPos 20 (0.5 *.* rotateV (pi+sparkD) accel) Nothing 3 10
|
& makeFlameletTimed oldPos 20 (0.5 *.* rotateV (pi+sparkD) accel) Nothing 3 10
|
||||||
| time > -200 = case thingHit of
|
| time > -200 = case thingHit of
|
||||||
|
|||||||
@@ -49,10 +49,10 @@ autoGun = defaultAutoGun
|
|||||||
, _wpAmmo = basicBullet
|
, _wpAmmo = basicBullet
|
||||||
}
|
}
|
||||||
autoFireMode, singleFireMode, autoGunNonTwistEff :: Creature -> World -> World
|
autoFireMode, singleFireMode, autoGunNonTwistEff :: Creature -> World -> World
|
||||||
autoFireMode = shootWithSound (fromIntegral autoGunSound)
|
autoFireMode = shootWithSound autoGunSound
|
||||||
. torqueBefore 0.05
|
. torqueBefore 0.05
|
||||||
$ autoGunNonTwistEff
|
$ autoGunNonTwistEff
|
||||||
singleFireMode = hammerCheck $ shootWithSound (fromIntegral autoGunSound) autoGunNonTwistEff
|
singleFireMode = hammerCheck $ shootWithSound autoGunSound autoGunNonTwistEff
|
||||||
autoGunNonTwistEff = withRecoil 40
|
autoGunNonTwistEff = withRecoil 40
|
||||||
. withRandomDir (autogunSpread/2)
|
. withRandomDir (autogunSpread/2)
|
||||||
. withMuzFlare
|
. withMuzFlare
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ moveGrenade 0 _ pID w = over projectiles (IM.delete pID)
|
|||||||
pj = _projectiles w IM.! pID
|
pj = _projectiles w IM.! pID
|
||||||
explosion = _pjPayload pj
|
explosion = _pjPayload pj
|
||||||
moveGrenade time dir pID w = case hitWl of
|
moveGrenade time dir pID w = case hitWl of
|
||||||
Just _ -> soundOnce (fromIntegral tapQuiet) updatedWorld
|
Just _ -> soundOnce tapQuiet updatedWorld
|
||||||
_ -> updatedWorld
|
_ -> updatedWorld
|
||||||
where
|
where
|
||||||
updatedWorld = updateV $ set (projectiles . ix pID . pjPos) finalPos
|
updatedWorld = updateV $ set (projectiles . ix pID . pjPos) finalPos
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ launcher = defaultGun
|
|||||||
, _wpReloadState = 0
|
, _wpReloadState = 0
|
||||||
, _itUseRate = 20
|
, _itUseRate = 20
|
||||||
, _itUseTime = 0
|
, _itUseTime = 0
|
||||||
, _itUse = shootWithSound (fromIntegral launcherSound) . aRocketWithItemParams
|
, _itUse = shootWithSound launcherSound . aRocketWithItemParams
|
||||||
, _wpSpread = 0.02
|
, _wpSpread = 0.02
|
||||||
, _wpRange = 20
|
, _wpRange = 20
|
||||||
, _itFloorPict = onLayer FlItLayer launcherPic
|
, _itFloorPict = onLayer FlItLayer launcherPic
|
||||||
@@ -92,14 +92,14 @@ pjThrust :: Int -> Projectile -> World -> World
|
|||||||
pjThrust i = pjEffTimeRange (st,et) doThrust
|
pjThrust i = pjEffTimeRange (st,et) doThrust
|
||||||
where
|
where
|
||||||
et | i == 0 = 36
|
et | i == 0 = 36
|
||||||
| otherwise = 40 - (fromIntegral i * 20)
|
| otherwise = 40 - (i * 20)
|
||||||
st = et - 100
|
st = et - 100
|
||||||
|
|
||||||
doThrust :: Projectile -> World -> World
|
doThrust :: Projectile -> World -> World
|
||||||
doThrust pj w = w
|
doThrust pj w = w
|
||||||
& randGen .~ g
|
& randGen .~ g
|
||||||
& projectiles . ix i . pjVel %~ (\v -> accel +.+ frict *.* v)
|
& projectiles . ix i . pjVel %~ (\v -> accel +.+ frict *.* v)
|
||||||
& soundFromPos (ShellSound i) newPos (fromIntegral smokeTrailSound) 1 250
|
& soundFromPos (ShellSound i) newPos smokeTrailSound 1 250
|
||||||
& makeFlameletTimed (oldPos -.- vel) 0 (vel +.+ rotateV (pi+sparkD) accel) Nothing 3 10
|
& makeFlameletTimed (oldPos -.- vel) 0 (vel +.+ rotateV (pi+sparkD) accel) Nothing 3 10
|
||||||
& smokeGen
|
& smokeGen
|
||||||
where
|
where
|
||||||
|
|||||||
@@ -83,22 +83,21 @@ rateIncAB startRate fastRate shooteff1 shooteff2 cr w
|
|||||||
Shoot a weapon rapidly after a warm up.
|
Shoot a weapon rapidly after a warm up.
|
||||||
Applies ammo check as well. -}
|
Applies ammo check as well. -}
|
||||||
withWarmUp
|
withWarmUp
|
||||||
:: Int -- ^ Warm up time (in frames)
|
:: Int -- ^ warm up sound id
|
||||||
-> (Creature -> World -> World)
|
-> (Creature -> World -> World)
|
||||||
-- ^ Shoot effect
|
-- ^ underlying effect
|
||||||
-> Creature
|
-> Creature
|
||||||
-> World
|
-> World
|
||||||
-> World
|
-> World
|
||||||
withWarmUp t f cr w
|
withWarmUp soundID f cr w
|
||||||
| reloadCondition = fromMaybe w $ startReloadingWeapon cr w
|
| reloadCondition = fromMaybe w $ startReloadingWeapon cr w
|
||||||
| _wpReloadState item /= 0 = w
|
| _wpReloadState item /= 0 = w
|
||||||
| curWarmUp < maxWarmUp = w
|
| curWarmUp < maxWarmUp = w
|
||||||
& pointerToItem . wpCurWarmUp +~ 2
|
& pointerToItem . wpCurWarmUp +~ 2
|
||||||
& soundFrom (CrWeaponSound cid) 26 2 0
|
& soundFrom (CrWeaponSound cid) soundID 2 0
|
||||||
| otherwise = w
|
| otherwise = w
|
||||||
& pointerToItem . wpCurWarmUp .~ maxWarmUp
|
& pointerToItem . wpCurWarmUp .~ maxWarmUp
|
||||||
& f cr
|
& f cr
|
||||||
-- & soundFrom (CrWeaponSound cid) 28 2 0
|
|
||||||
where
|
where
|
||||||
cid = _crID cr
|
cid = _crID cr
|
||||||
itRef = _crInvSel cr
|
itRef = _crInvSel cr
|
||||||
@@ -106,7 +105,6 @@ withWarmUp t f cr w
|
|||||||
pointerToItem = creatures . ix cid . crInv . ix itRef
|
pointerToItem = creatures . ix cid . crInv . ix itRef
|
||||||
curWarmUp = _wpCurWarmUp item
|
curWarmUp = _wpCurWarmUp item
|
||||||
maxWarmUp = _wpMaxWarmUp item
|
maxWarmUp = _wpMaxWarmUp item
|
||||||
fState = _itUseTime item
|
|
||||||
reloadCondition = _wpLoadedAmmo item == 0
|
reloadCondition = _wpLoadedAmmo item == 0
|
||||||
{- | Adds a sound to a creature based world effect.
|
{- | Adds a sound to a creature based world effect.
|
||||||
The sound is emitted from the creature's position. -}
|
The sound is emitted from the creature's position. -}
|
||||||
|
|||||||
@@ -1,7 +1,22 @@
|
|||||||
{-# LANGUAGE TemplateHaskell #-}
|
{-# LANGUAGE TemplateHaskell #-}
|
||||||
{-# LANGUAGE StrictData #-}
|
{-# LANGUAGE StrictData #-}
|
||||||
module Dodge.LevelGen.Data
|
module Dodge.LevelGen.Data
|
||||||
where
|
( PSType (..)
|
||||||
|
, PlacementSpot (..)
|
||||||
|
, Placement (..)
|
||||||
|
, sPS
|
||||||
|
-- lenses
|
||||||
|
, placementSpot
|
||||||
|
, psType
|
||||||
|
, psPos
|
||||||
|
, psRot
|
||||||
|
, putID
|
||||||
|
, pwPoly
|
||||||
|
, pwWall
|
||||||
|
, unPutCrit
|
||||||
|
, groupPlacementID
|
||||||
|
, groupUpdate
|
||||||
|
) where
|
||||||
import Dodge.Data
|
import Dodge.Data
|
||||||
import Picture
|
import Picture
|
||||||
import Polyhedra.Data
|
import Polyhedra.Data
|
||||||
@@ -36,9 +51,7 @@ data Placement
|
|||||||
= SinglePlacement {_placementSpot :: PlacementSpot }
|
= SinglePlacement {_placementSpot :: PlacementSpot }
|
||||||
| GroupedPlacement
|
| GroupedPlacement
|
||||||
{_groupPlacementID :: Int
|
{_groupPlacementID :: Int
|
||||||
-- ,_groupPlacementUpdate :: World -> Placement -> (World, Placement)
|
|
||||||
,_groupUpdate :: World -> [Placement] -> World
|
,_groupUpdate :: World -> [Placement] -> World
|
||||||
-- ,_groupPlacementFunc :: [PSType] -> PSType -> World -> World
|
|
||||||
,_placementSpot :: PlacementSpot
|
,_placementSpot :: PlacementSpot
|
||||||
}
|
}
|
||||||
sPS :: Point2 -> Float -> PSType -> Placement
|
sPS :: Point2 -> Float -> PSType -> Placement
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ addSoundToDoor i pld hwd (x:ys) = f x : ys
|
|||||||
where
|
where
|
||||||
g dm w
|
g dm w
|
||||||
| dist wp pld > 2 && dist wp hwd > 2
|
| dist wp pld > 2 && dist wp hwd > 2
|
||||||
= soundFrom (WallSound i) (fromIntegral doorSound) 1 0 $ dm w
|
= soundFrom (WallSound i) doorSound 1 0 $ dm w
|
||||||
| otherwise = dm w
|
| otherwise = dm w
|
||||||
where
|
where
|
||||||
wp = snd $ _wlLine (_walls w IM.! i)
|
wp = snd $ _wlLine (_walls w IM.! i)
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import qualified Data.IntMap.Strict as IM
|
|||||||
import Data.Graph.Inductive hiding ((&))
|
import Data.Graph.Inductive hiding ((&))
|
||||||
--import Data.Graph.Inductive.NodeMap
|
--import Data.Graph.Inductive.NodeMap
|
||||||
|
|
||||||
pairsToGraph :: (Ord a, Eq a, Eq b) => (a -> a -> b) -> [(a,a)] -> Gr a b
|
pairsToGraph :: (Ord a, Eq b) => (a -> a -> b) -> [(a,a)] -> Gr a b
|
||||||
pairsToGraph f pairs =
|
pairsToGraph f pairs =
|
||||||
let nodes' = nub (map fst pairs ++ map snd pairs)
|
let nodes' = nub (map fst pairs ++ map snd pairs)
|
||||||
pairs' = map (\(x,y)->(x,y,f x y)) pairs
|
pairs' = map (\(x,y)->(x,y,f x y)) pairs
|
||||||
|
|||||||
@@ -1,2 +0,0 @@
|
|||||||
module Dodge.Lock
|
|
||||||
where
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
{-# LANGUAGE TemplateHaskell #-}
|
|
||||||
{-# LANGUAGE StrictData #-}
|
|
||||||
module Dodge.Lock.Data
|
|
||||||
where
|
|
||||||
import Dodge.Data
|
|
||||||
import Control.Lens
|
|
||||||
|
|
||||||
newtype Lock = Lock
|
|
||||||
{ _lkUnlocker :: Unlocker
|
|
||||||
}
|
|
||||||
|
|
||||||
newtype Unlocker
|
|
||||||
= ItemUnlocker Item
|
|
||||||
|
|
||||||
makeLenses ''Lock
|
|
||||||
@@ -13,5 +13,5 @@ linksOnPath r = all pointOnPath linkPoints
|
|||||||
pathConnected :: Room -> Bool
|
pathConnected :: Room -> Bool
|
||||||
pathConnected = isSingleton . pairsToSCC . _rmPath
|
pathConnected = isSingleton . pairsToSCC . _rmPath
|
||||||
where
|
where
|
||||||
isSingleton [] = True
|
isSingleton [_] = True
|
||||||
isSingleton _ = False
|
isSingleton _ = False
|
||||||
|
|||||||
@@ -1,14 +1,20 @@
|
|||||||
{-# LANGUAGE TemplateHaskell #-}
|
{-# LANGUAGE TemplateHaskell #-}
|
||||||
{-# LANGUAGE StrictData #-}
|
{-# LANGUAGE StrictData #-}
|
||||||
module Dodge.Room.Data
|
module Dodge.Room.Data
|
||||||
where
|
( Room (..)
|
||||||
|
, rmPolys
|
||||||
|
, rmLinks
|
||||||
|
, rmPath
|
||||||
|
, rmPS
|
||||||
|
, rmBound
|
||||||
|
, rmFloor
|
||||||
|
) where
|
||||||
import Dodge.LevelGen.Data
|
import Dodge.LevelGen.Data
|
||||||
--import Geometry
|
--import Geometry
|
||||||
import Geometry.Data
|
import Geometry.Data
|
||||||
import Data.Tile
|
import Data.Tile
|
||||||
|
|
||||||
import Control.Lens
|
import Control.Lens
|
||||||
|
|
||||||
{-
|
{-
|
||||||
The '_rmPolys' list states which polygons should be cut out to form the indestructible walls of the room.
|
The '_rmPolys' list states which polygons should be cut out to form the indestructible walls of the room.
|
||||||
Link pairs contain a position and rotation to attach to another room;
|
Link pairs contain a position and rotation to attach to another room;
|
||||||
|
|||||||
@@ -33,8 +33,7 @@ randomiseAllLinks r = do
|
|||||||
return $ r {_rmLinks = newLinks}
|
return $ r {_rmLinks = newLinks}
|
||||||
|
|
||||||
randomiseLinksBy
|
randomiseLinksBy
|
||||||
:: RandomGen g
|
:: ( [(Point2,Float)] -> State g [(Point2,Float)] )
|
||||||
=> ( [(Point2,Float)] -> State g [(Point2,Float)] )
|
|
||||||
-> Room
|
-> Room
|
||||||
-> State g Room
|
-> State g Room
|
||||||
randomiseLinksBy f r = do
|
randomiseLinksBy f r = do
|
||||||
|
|||||||
@@ -231,8 +231,7 @@ randomFourCornerRoom = do
|
|||||||
{- | Creates room with a central vault with doors around it.
|
{- | Creates room with a central vault with doors around it.
|
||||||
-}
|
-}
|
||||||
centerVaultRoom
|
centerVaultRoom
|
||||||
:: RandomGen g
|
:: Int -- ^ Door id
|
||||||
=> Int -- ^ Door id
|
|
||||||
-> Float -- ^ Width
|
-> Float -- ^ Width
|
||||||
-> Float -- ^ Height
|
-> Float -- ^ Height
|
||||||
-> Float -- ^ Vault dimensions
|
-> Float -- ^ Vault dimensions
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ litCorridor90 = do
|
|||||||
, _rmBound = [poly]
|
, _rmBound = [poly]
|
||||||
}
|
}
|
||||||
|
|
||||||
noWeaponTest :: RandomGen g => State g (Tree (Either Room Room))
|
noWeaponTest :: State g (Tree (Either Room Room))
|
||||||
noWeaponTest = do
|
noWeaponTest = do
|
||||||
undefined
|
undefined
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import Geometry
|
|||||||
--import Data.List
|
--import Data.List
|
||||||
import Control.Monad.State
|
import Control.Monad.State
|
||||||
--import Control.Lens
|
--import Control.Lens
|
||||||
import System.Random
|
--import System.Random
|
||||||
{- | A triangular room with loot at the top (with 'PutID' 2),
|
{- | A triangular room with loot at the top (with 'PutID' 2),
|
||||||
creatures in the bottom two corners (with 'PutID' 0),
|
creatures in the bottom two corners (with 'PutID' 0),
|
||||||
and (single) entrance bottom middle. -}
|
and (single) entrance bottom middle. -}
|
||||||
@@ -50,7 +50,7 @@ triLootRoom w h = pure $ defaultRoom
|
|||||||
]
|
]
|
||||||
base = rectNSWE 20 (-80) (-20) 20
|
base = rectNSWE 20 (-80) (-20) 20
|
||||||
{- | Create a random room with one entrance containing given creatures and items. -}
|
{- | Create a random room with one entrance containing given creatures and items. -}
|
||||||
lootRoom :: RandomGen g => [Creature] -> [Item] -> State g Room
|
lootRoom :: [Creature] -> [Item] -> State g Room
|
||||||
lootRoom crs itms = do
|
lootRoom crs itms = do
|
||||||
let w = 300
|
let w = 300
|
||||||
h = 700
|
h = 700
|
||||||
|
|||||||
+6
-8
@@ -39,8 +39,8 @@ New sounds with the same keys as
|
|||||||
already playing sounds are merged as follows:
|
already playing sounds are merged as follows:
|
||||||
|
|
||||||
* '_soundChannel' is set to the old value
|
* '_soundChannel' is set to the old value
|
||||||
* if the old '_soundStatus' was 'FadingOut', it is set to the new value (can restart playback with 'ToStart')
|
* if the old sound is not fading and the chunk is the same, '_soundStatus' is set to the old value
|
||||||
* other fields are set to the new value.
|
* all other values are set to the new values
|
||||||
|
|
||||||
In the update:
|
In the update:
|
||||||
|
|
||||||
@@ -51,18 +51,16 @@ In the update:
|
|||||||
-}
|
-}
|
||||||
playAndUpdate :: Ord a => SoundData a -> M.Map a Sound -> IO (M.Map a Sound)
|
playAndUpdate :: Ord a => SoundData a -> M.Map a Sound -> IO (M.Map a Sound)
|
||||||
playAndUpdate sData newSounds
|
playAndUpdate sData newSounds
|
||||||
= updateSounds (_loadedChunks sData) (M.unionWith mergeSound newSounds (_playingSounds sData))
|
= updateSounds (_loadedChunks sData) (M.unionWith mergeSound (_playingSounds sData) newSounds)
|
||||||
|
|
||||||
mergeSound :: Sound -> Sound -> Sound
|
mergeSound :: Sound -> Sound -> Sound
|
||||||
mergeSound newS oldS
|
mergeSound oldS newS
|
||||||
| _soundStatus oldS == FadingOut
|
| _soundChunkID newS == _soundChunkID oldS && _soundStatus oldS /= FadingOut
|
||||||
= newS & soundChannel .~ _soundChannel oldS
|
|
||||||
| _soundChunkID newS == _soundChunkID oldS
|
|
||||||
= newS & soundChannel .~ _soundChannel oldS
|
= newS & soundChannel .~ _soundChannel oldS
|
||||||
& soundStatus .~ _soundStatus oldS
|
& soundStatus .~ _soundStatus oldS
|
||||||
| otherwise = newS & soundChannel .~ _soundChannel oldS
|
| otherwise = newS & soundChannel .~ _soundChannel oldS
|
||||||
|
|
||||||
updateSounds :: Ord a => IM.IntMap Mix.Chunk -> M.Map a Sound -> IO (M.Map a Sound)
|
updateSounds :: IM.IntMap Mix.Chunk -> M.Map a Sound -> IO (M.Map a Sound)
|
||||||
updateSounds sd ss = do
|
updateSounds sd ss = do
|
||||||
may <- mapM (runMaybeT . updateSound sd) ss
|
may <- mapM (runMaybeT . updateSound sd) ss
|
||||||
return $ M.mapMaybe id may
|
return $ M.mapMaybe id may
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
import Test.QuickCheck
|
import Test.QuickCheck
|
||||||
|
import Test.HUnit
|
||||||
|
import Dodge.Room.CheckConsistency
|
||||||
|
|
||||||
import Dodge.LevelGen.StaticWalls
|
import Dodge.LevelGen.StaticWalls
|
||||||
import Geometry
|
import Geometry
|
||||||
@@ -51,3 +53,5 @@ genTris = listOf genTri
|
|||||||
|
|
||||||
--
|
--
|
||||||
--[[(0.0,1.0),(3.0,4.0),(5.0,5.0)],[(2.0,0.0),(2.0,4.0),(1.0,1.0)],[(5.0,5.0),(2.0,2.0),(1.0,3.0)]]
|
--[[(0.0,1.0),(3.0,4.0),(5.0,5.0)],[(2.0,0.0),(2.0,4.0),(1.0,1.0)],[(5.0,5.0),(2.0,2.0),(1.0,3.0)]]
|
||||||
|
--
|
||||||
|
testRoom rm = TestCase "Room links connected" (linksOnPath rm)
|
||||||
|
|||||||
Reference in New Issue
Block a user