Fix remote camera bug
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
module Dodge.Config.KeyConfig
|
module Dodge.Config.KeyConfig
|
||||||
( KeyConfigSDL (..)
|
( KeyConfigSDL (..)
|
||||||
, defaultKeyConfigSDL
|
, defaultKeyConfigSDL
|
||||||
|
, loadKeyConfig
|
||||||
)
|
)
|
||||||
where
|
where
|
||||||
--import Data.Aeson
|
--import Data.Aeson
|
||||||
@@ -55,3 +56,6 @@ defaultKeyConfigSDL =
|
|||||||
, newMapKey = SDL.ScancodeN
|
, newMapKey = SDL.ScancodeN
|
||||||
, modifierKey = SDL.ScancodeCapsLock
|
, modifierKey = SDL.ScancodeCapsLock
|
||||||
}
|
}
|
||||||
|
|
||||||
|
loadKeyConfig :: IO KeyConfigSDL
|
||||||
|
loadKeyConfig = return defaultKeyConfigSDL
|
||||||
|
|||||||
@@ -170,6 +170,7 @@ startInventory = IM.fromList (zip [0..20]
|
|||||||
,multGun
|
,multGun
|
||||||
,boosterGun
|
,boosterGun
|
||||||
,remoteLauncher
|
,remoteLauncher
|
||||||
|
,remoteBomb
|
||||||
,grenade
|
,grenade
|
||||||
,spawnGun (lamp 20)
|
,spawnGun (lamp 20)
|
||||||
,lasGun
|
,lasGun
|
||||||
|
|||||||
+18
-14
@@ -86,6 +86,7 @@ pistol = defaultGun
|
|||||||
}
|
}
|
||||||
pistolPic :: Picture
|
pistolPic :: Picture
|
||||||
pistolPic = color green $ polygon $ rectNESW 5 5 (-5) (-5)
|
pistolPic = color green $ polygon $ rectNESW 5 5 (-5) (-5)
|
||||||
|
|
||||||
useAmmoParams :: Item -> Creature -> World -> World
|
useAmmoParams :: Item -> Creature -> World -> World
|
||||||
useAmmoParams it = withVelWthHiteff (_amBulVel b) (_amBulWth b) (_amBulEff b)
|
useAmmoParams it = withVelWthHiteff (_amBulVel b) (_amBulWth b) (_amBulEff b)
|
||||||
where
|
where
|
||||||
@@ -134,7 +135,10 @@ teslaGun = defaultGun
|
|||||||
, _wpReloadState = 0
|
, _wpReloadState = 0
|
||||||
, _itUseRate = 0
|
, _itUseRate = 0
|
||||||
, _itUseTime = 0
|
, _itUseTime = 0
|
||||||
, _itUse = \_ -> shoot aTeslaArc
|
, _itUse = \_ -> aTeslaArc
|
||||||
|
, _itUseModifiers =
|
||||||
|
[ shootWithSoundForI 25 1
|
||||||
|
]
|
||||||
, _wpSpread = 0.001
|
, _wpSpread = 0.001
|
||||||
, _wpRange = 20
|
, _wpRange = 20
|
||||||
, _itFloorPict = onLayer FlItLayer teslaGunPic
|
, _itFloorPict = onLayer FlItLayer teslaGunPic
|
||||||
@@ -162,7 +166,10 @@ lasGun = defaultAutoGun
|
|||||||
, _wpReloadState = 0
|
, _wpReloadState = 0
|
||||||
, _itUseRate = 0
|
, _itUseRate = 0
|
||||||
, _itUseTime = 0
|
, _itUseTime = 0
|
||||||
, _itUse = \_ -> shoot aLaser
|
, _itUse = \_ -> aLaser
|
||||||
|
, _itUseModifiers =
|
||||||
|
[ shootWithSoundForI 24 1
|
||||||
|
]
|
||||||
, _wpSpread = 0.001
|
, _wpSpread = 0.001
|
||||||
, _wpRange = 20
|
, _wpRange = 20
|
||||||
, _itFloorPict = onLayer FlItLayer lasGunPic
|
, _itFloorPict = onLayer FlItLayer lasGunPic
|
||||||
@@ -246,7 +253,10 @@ remoteLauncher = defaultGun
|
|||||||
, _wpReloadState = 0
|
, _wpReloadState = 0
|
||||||
, _itUseRate = 10
|
, _itUseRate = 10
|
||||||
, _itUseTime = 0
|
, _itUseTime = 0
|
||||||
, _itUse = \_ -> hammerCheck fireRemoteLauncher
|
, _itUse = \_ -> fireRemoteLauncher
|
||||||
|
, _itUseModifiers =
|
||||||
|
[ hammerCheckI
|
||||||
|
]
|
||||||
, _wpSpread = 0.02
|
, _wpSpread = 0.02
|
||||||
, _wpRange = 20
|
, _wpRange = 20
|
||||||
, _itFloorPict = onLayer FlItLayer $ color cyan $ polygon $ rectNESW 5 5 (-5) (-5)
|
, _itFloorPict = onLayer FlItLayer $ color cyan $ polygon $ rectNESW 5 5 (-5) (-5)
|
||||||
@@ -529,14 +539,8 @@ boosterGun = defaultGun
|
|||||||
}
|
}
|
||||||
|
|
||||||
aTeslaArc :: Creature -> World -> World
|
aTeslaArc :: Creature -> World -> World
|
||||||
aTeslaArc cr w = aTeslaArc' cr $ soundFrom (CrWeaponSound cid) 25 1 0 w
|
aTeslaArc cr w
|
||||||
where
|
|
||||||
cid = _crID cr
|
|
||||||
|
|
||||||
aTeslaArc' :: Creature -> World -> World
|
|
||||||
aTeslaArc' cr w
|
|
||||||
= teslaGunFlashAt (pos +.+ 5 *.* unitVectorAtAngle dir)
|
= teslaGunFlashAt (pos +.+ 5 *.* unitVectorAtAngle dir)
|
||||||
-- $ over projectiles (IM.insert i (makeTeslaArcAt i pos dir))
|
|
||||||
$ set randGen g w
|
$ set randGen g w
|
||||||
& particles %~ (makeTeslaArcAt pos dir :)
|
& particles %~ (makeTeslaArcAt pos dir :)
|
||||||
where
|
where
|
||||||
@@ -607,7 +611,7 @@ pointToItem (OnFloor flid) = floorItems . ix flid . flIt
|
|||||||
retireRemoteRocket :: Int -> Int -> Int -> World -> World
|
retireRemoteRocket :: Int -> Int -> Int -> World -> World
|
||||||
retireRemoteRocket itid 0 pjid w =
|
retireRemoteRocket itid 0 pjid w =
|
||||||
set (pointToItem (_itemPositions w IM.! itid) . itAttachment . _Just . scopePos) (V2 0 0)
|
set (pointToItem (_itemPositions w IM.! itid) . itAttachment . _Just . scopePos) (V2 0 0)
|
||||||
$ set (pointToItem (_itemPositions w IM.! itid) . itUse) (\_ -> hammerCheck fireRemoteLauncher)
|
$ set (pointToItem (_itemPositions w IM.! itid) . itUse) (\_ -> fireRemoteLauncher)
|
||||||
(w & projectiles %~ IM.delete pjid)
|
(w & projectiles %~ IM.delete pjid)
|
||||||
retireRemoteRocket itid t pjid w = setScope w
|
retireRemoteRocket itid t pjid w = setScope w
|
||||||
& projectiles . ix pjid . pjUpdate .~ (\_ -> retireRemoteRocket itid (t-1) pjid)
|
& projectiles . ix pjid . pjUpdate .~ (\_ -> retireRemoteRocket itid (t-1) pjid)
|
||||||
@@ -761,13 +765,13 @@ fireRemoteLauncher cr w = setLocation
|
|||||||
$ resetFire
|
$ resetFire
|
||||||
$ resetName
|
$ resetName
|
||||||
$ soundOnce launcherSound
|
$ soundOnce launcherSound
|
||||||
$ over projectiles remRocket w
|
$ over projectiles addRemRocket w
|
||||||
where
|
where
|
||||||
i = IM.newKey $ _projectiles w
|
i = IM.newKey $ _projectiles w
|
||||||
cid = _crID cr
|
cid = _crID cr
|
||||||
dir = _crDir cr
|
dir = _crDir cr
|
||||||
pos = _crPos cr +.+ rotateV dir (V2 (_crRad cr + 1) 0)
|
pos = _crPos cr +.+ rotateV dir (V2 (_crRad cr + 1) 0)
|
||||||
remRocket = IM.insert i $ Shell
|
addRemRocket = IM.insert i $ Shell
|
||||||
{ _pjPos = pos
|
{ _pjPos = pos
|
||||||
, _pjStartPos = pos
|
, _pjStartPos = pos
|
||||||
, _pjVel = rotateV dir (V2 1 0)
|
, _pjVel = rotateV dir (V2 1 0)
|
||||||
@@ -784,7 +788,7 @@ fireRemoteLauncher cr w = setLocation
|
|||||||
newitid = IM.newKey $ _itemPositions w
|
newitid = IM.newKey $ _itemPositions w
|
||||||
maybeitid = cr ^? crInv . ix j . itID . _Just
|
maybeitid = cr ^? crInv . ix j . itID . _Just
|
||||||
resetFire = set (creatures . ix cid . crInv . ix j . itUse)
|
resetFire = set (creatures . ix cid . crInv . ix j . itUse)
|
||||||
$ \_ -> hammerCheck $ \_ -> explodeRemoteRocket itid i
|
$ \_ _ -> explodeRemoteRocket itid i
|
||||||
resetName = set (creatures . ix cid . crInv . ix j . itName) "REMOTEROCKET"
|
resetName = set (creatures . ix cid . crInv . ix j . itName) "REMOTEROCKET"
|
||||||
setLocation :: World -> World
|
setLocation :: World -> World
|
||||||
setLocation w' = case maybeitid of
|
setLocation w' = case maybeitid of
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import Dodge.Picture
|
|||||||
--import Dodge.Picture.Layer
|
--import Dodge.Picture.Layer
|
||||||
import Dodge.Item.Attachment.Data
|
import Dodge.Item.Attachment.Data
|
||||||
--import Dodge.Base
|
--import Dodge.Base
|
||||||
import Dodge.SoundLogic
|
--import Dodge.SoundLogic
|
||||||
import Dodge.WorldEvent.SpawnParticle
|
import Dodge.WorldEvent.SpawnParticle
|
||||||
import Dodge.WorldEvent.ThingsHit
|
import Dodge.WorldEvent.ThingsHit
|
||||||
import Dodge.WorldEvent.HelperParticle
|
import Dodge.WorldEvent.HelperParticle
|
||||||
@@ -25,7 +25,6 @@ import qualified Data.Sequence as Seq
|
|||||||
|
|
||||||
aLaser :: Creature -> World -> World
|
aLaser :: Creature -> World -> World
|
||||||
aLaser cr w = over particles (makeLaserAt phaseV pos dir : )
|
aLaser cr w = over particles (makeLaserAt phaseV pos dir : )
|
||||||
$ soundFrom LasSound 24 1 0
|
|
||||||
$ laserGunFlashAt (pos +.+ 5 *.* unitVectorAtAngle dir)
|
$ laserGunFlashAt (pos +.+ 5 *.* unitVectorAtAngle dir)
|
||||||
w
|
w
|
||||||
where
|
where
|
||||||
|
|||||||
@@ -168,6 +168,35 @@ withSidePushAfter maxSide eff cr w = over (creatures . ix cid) push . eff cr $ w
|
|||||||
push = over crPos (+.+ rotateV (_crDir cr) (V2 0 (pushAmount / _crMass cr)))
|
push = over crPos (+.+ rotateV (_crDir cr) (V2 0 (pushAmount / _crMass cr)))
|
||||||
(pushAmount, _) = randomR (-maxSide,maxSide) $ _randGen w
|
(pushAmount, _) = randomR (-maxSide,maxSide) $ _randGen w
|
||||||
{- | Applies a world effect and sound effect after an ammo check. -}
|
{- | Applies a world effect and sound effect after an ammo check. -}
|
||||||
|
shootWithSoundForI
|
||||||
|
:: Int -- ^ Sound identifier
|
||||||
|
-> Int -- ^ Frames to play
|
||||||
|
-> (Item -> Creature -> World -> World)
|
||||||
|
-- ^ underlying effect
|
||||||
|
-> Item
|
||||||
|
-> Creature
|
||||||
|
-> World
|
||||||
|
-> World
|
||||||
|
shootWithSoundForI soundid playTime f item cr w
|
||||||
|
| fireCondition = soundFromPos (CrWeaponSound cid) cpos soundid playTime 0
|
||||||
|
$ f item cr
|
||||||
|
$ w
|
||||||
|
& pointerToItem %~
|
||||||
|
( ( wpLoadedAmmo -~ 1 )
|
||||||
|
. ( itUseTime .~ _itUseRate item)
|
||||||
|
)
|
||||||
|
| reloadCondition = fromMaybe w $ startReloadingWeapon cr w
|
||||||
|
| otherwise = w
|
||||||
|
where
|
||||||
|
cid = _crID cr
|
||||||
|
cpos = _crPos cr
|
||||||
|
itRef = _crInvSel cr
|
||||||
|
pointerToItem = creatures . ix cid . crInv . ix itRef
|
||||||
|
fireCondition = _wpReloadState item == 0
|
||||||
|
&& _itUseTime item == 0
|
||||||
|
&& _wpLoadedAmmo item > 0
|
||||||
|
reloadCondition = _wpLoadedAmmo item == 0
|
||||||
|
{- | Applies a world effect and sound effect after an ammo check. -}
|
||||||
shootWithSoundFor
|
shootWithSoundFor
|
||||||
:: Int -- ^ Sound identifier
|
:: Int -- ^ Sound identifier
|
||||||
-> Int -- ^ Frames to play
|
-> Int -- ^ Frames to play
|
||||||
|
|||||||
+13
-2
@@ -45,7 +45,8 @@ doDrawing pdata w = do
|
|||||||
wins = V2 (getWindowX w) (getWindowY w)
|
wins = V2 (getWindowX w) (getWindowY w)
|
||||||
(wallPointsCol,windowPoints) = wallsAndWindows w
|
(wallPointsCol,windowPoints) = wallsAndWindows w
|
||||||
lightPoints = lightsForGloom w
|
lightPoints = lightsForGloom w
|
||||||
viewFroms = _cameraViewFrom w
|
viewFroms@(V2 vfx vfy) = _cameraViewFrom w
|
||||||
|
viewFrom3d = Vector3 vfx vfy 20
|
||||||
shadV = _pictureShaders pdata
|
shadV = _pictureShaders pdata
|
||||||
-- bind as much data into vbos as feasible at this point
|
-- bind as much data into vbos as feasible at this point
|
||||||
-- poke wall points and colors
|
-- poke wall points and colors
|
||||||
@@ -72,10 +73,20 @@ doDrawing pdata w = do
|
|||||||
clear [ColorBuffer,DepthBuffer]
|
clear [ColorBuffer,DepthBuffer]
|
||||||
depthFunc $= Just Less
|
depthFunc $= Just Less
|
||||||
|
|
||||||
-- draw wall occlusions from your point of view
|
-- draw wall occlusions from the camera's point of view
|
||||||
|
currentProgram $= Just (_shaderProgram $ _lightingSurfaceShader pdata)
|
||||||
|
uniform (head $ _shaderCustomUnis $ _lightingSurfaceShader pdata)
|
||||||
|
$= viewFrom3d
|
||||||
|
currentProgram $= Just (_shaderProgram $ _lightingOccludeShader pdata)
|
||||||
|
uniform (head $ _shaderCustomUnis $ _lightingOccludeShader pdata)
|
||||||
|
$= viewFrom3d
|
||||||
|
currentProgram $= Just (_shaderProgram $ _lightingWallShader pdata)
|
||||||
|
uniform (head $ _shaderCustomUnis $ _lightingWallShader pdata)
|
||||||
|
$= viewFrom3d
|
||||||
drawShader (_lightingOccludeShader pdata) nWalls
|
drawShader (_lightingOccludeShader pdata) nWalls
|
||||||
-- this might only work because the uniform has been correctly set
|
-- this might only work because the uniform has been correctly set
|
||||||
-- elsewhere, beware
|
-- elsewhere, beware
|
||||||
|
-- indeed this is the case: this needs fixing
|
||||||
|
|
||||||
if w ^. config . wall_textured
|
if w ^. config . wall_textured
|
||||||
then renderTextureWalls pdata nWalls
|
then renderTextureWalls pdata nWalls
|
||||||
|
|||||||
+4
-3
@@ -38,11 +38,12 @@ createLightMap pdata lightPoints nWalls nSils nsurfVs = do
|
|||||||
clear [ColorBuffer,DepthBuffer]
|
clear [ColorBuffer,DepthBuffer]
|
||||||
--colorMask $= Color4 Disabled Disabled Disabled Disabled
|
--colorMask $= Color4 Disabled Disabled Disabled Disabled
|
||||||
cullFace $= Just Back
|
cullFace $= Just Back
|
||||||
-- draw wall surfaces from your point of view in order to set z buffer
|
-- we assume that the camera position uniforms have been correctly set elsewhere
|
||||||
|
-- draw wall surfaces from the camera's point of view in order to set z buffer
|
||||||
drawShader (_lightingWallShader pdata) nWalls
|
drawShader (_lightingWallShader pdata) nWalls
|
||||||
-- draw foreground elements from your point of view to set z buffer
|
-- draw foreground elements the camera's your point of view to set z buffer
|
||||||
drawShader (_lightingSurfaceShader pdata) nsurfVs
|
drawShader (_lightingSurfaceShader pdata) nsurfVs
|
||||||
-- draw wall occlusions from your point of view
|
-- draw wall occlusions from the camera's point of view
|
||||||
drawShader (_lightingOccludeShader pdata) nWalls
|
drawShader (_lightingOccludeShader pdata) nWalls
|
||||||
--hypothesis: the above three draw calls only work because the
|
--hypothesis: the above three draw calls only work because the
|
||||||
--uniform was set to your position, that being the last light source in the list
|
--uniform was set to your position, that being the last light source in the list
|
||||||
|
|||||||
Reference in New Issue
Block a user