Fix remote camera bug
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
module Dodge.Config.KeyConfig
|
||||
( KeyConfigSDL (..)
|
||||
, defaultKeyConfigSDL
|
||||
, loadKeyConfig
|
||||
)
|
||||
where
|
||||
--import Data.Aeson
|
||||
@@ -55,3 +56,6 @@ defaultKeyConfigSDL =
|
||||
, newMapKey = SDL.ScancodeN
|
||||
, modifierKey = SDL.ScancodeCapsLock
|
||||
}
|
||||
|
||||
loadKeyConfig :: IO KeyConfigSDL
|
||||
loadKeyConfig = return defaultKeyConfigSDL
|
||||
|
||||
@@ -170,6 +170,7 @@ startInventory = IM.fromList (zip [0..20]
|
||||
,multGun
|
||||
,boosterGun
|
||||
,remoteLauncher
|
||||
,remoteBomb
|
||||
,grenade
|
||||
,spawnGun (lamp 20)
|
||||
,lasGun
|
||||
|
||||
+18
-14
@@ -86,6 +86,7 @@ pistol = defaultGun
|
||||
}
|
||||
pistolPic :: Picture
|
||||
pistolPic = color green $ polygon $ rectNESW 5 5 (-5) (-5)
|
||||
|
||||
useAmmoParams :: Item -> Creature -> World -> World
|
||||
useAmmoParams it = withVelWthHiteff (_amBulVel b) (_amBulWth b) (_amBulEff b)
|
||||
where
|
||||
@@ -134,7 +135,10 @@ teslaGun = defaultGun
|
||||
, _wpReloadState = 0
|
||||
, _itUseRate = 0
|
||||
, _itUseTime = 0
|
||||
, _itUse = \_ -> shoot aTeslaArc
|
||||
, _itUse = \_ -> aTeslaArc
|
||||
, _itUseModifiers =
|
||||
[ shootWithSoundForI 25 1
|
||||
]
|
||||
, _wpSpread = 0.001
|
||||
, _wpRange = 20
|
||||
, _itFloorPict = onLayer FlItLayer teslaGunPic
|
||||
@@ -162,7 +166,10 @@ lasGun = defaultAutoGun
|
||||
, _wpReloadState = 0
|
||||
, _itUseRate = 0
|
||||
, _itUseTime = 0
|
||||
, _itUse = \_ -> shoot aLaser
|
||||
, _itUse = \_ -> aLaser
|
||||
, _itUseModifiers =
|
||||
[ shootWithSoundForI 24 1
|
||||
]
|
||||
, _wpSpread = 0.001
|
||||
, _wpRange = 20
|
||||
, _itFloorPict = onLayer FlItLayer lasGunPic
|
||||
@@ -246,7 +253,10 @@ remoteLauncher = defaultGun
|
||||
, _wpReloadState = 0
|
||||
, _itUseRate = 10
|
||||
, _itUseTime = 0
|
||||
, _itUse = \_ -> hammerCheck fireRemoteLauncher
|
||||
, _itUse = \_ -> fireRemoteLauncher
|
||||
, _itUseModifiers =
|
||||
[ hammerCheckI
|
||||
]
|
||||
, _wpSpread = 0.02
|
||||
, _wpRange = 20
|
||||
, _itFloorPict = onLayer FlItLayer $ color cyan $ polygon $ rectNESW 5 5 (-5) (-5)
|
||||
@@ -529,14 +539,8 @@ boosterGun = defaultGun
|
||||
}
|
||||
|
||||
aTeslaArc :: Creature -> World -> World
|
||||
aTeslaArc cr w = aTeslaArc' cr $ soundFrom (CrWeaponSound cid) 25 1 0 w
|
||||
where
|
||||
cid = _crID cr
|
||||
|
||||
aTeslaArc' :: Creature -> World -> World
|
||||
aTeslaArc' cr w
|
||||
aTeslaArc cr w
|
||||
= teslaGunFlashAt (pos +.+ 5 *.* unitVectorAtAngle dir)
|
||||
-- $ over projectiles (IM.insert i (makeTeslaArcAt i pos dir))
|
||||
$ set randGen g w
|
||||
& particles %~ (makeTeslaArcAt pos dir :)
|
||||
where
|
||||
@@ -607,7 +611,7 @@ pointToItem (OnFloor flid) = floorItems . ix flid . flIt
|
||||
retireRemoteRocket :: Int -> Int -> Int -> World -> World
|
||||
retireRemoteRocket itid 0 pjid w =
|
||||
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)
|
||||
retireRemoteRocket itid t pjid w = setScope w
|
||||
& projectiles . ix pjid . pjUpdate .~ (\_ -> retireRemoteRocket itid (t-1) pjid)
|
||||
@@ -761,13 +765,13 @@ fireRemoteLauncher cr w = setLocation
|
||||
$ resetFire
|
||||
$ resetName
|
||||
$ soundOnce launcherSound
|
||||
$ over projectiles remRocket w
|
||||
$ over projectiles addRemRocket w
|
||||
where
|
||||
i = IM.newKey $ _projectiles w
|
||||
cid = _crID cr
|
||||
dir = _crDir cr
|
||||
pos = _crPos cr +.+ rotateV dir (V2 (_crRad cr + 1) 0)
|
||||
remRocket = IM.insert i $ Shell
|
||||
addRemRocket = IM.insert i $ Shell
|
||||
{ _pjPos = pos
|
||||
, _pjStartPos = pos
|
||||
, _pjVel = rotateV dir (V2 1 0)
|
||||
@@ -784,7 +788,7 @@ fireRemoteLauncher cr w = setLocation
|
||||
newitid = IM.newKey $ _itemPositions w
|
||||
maybeitid = cr ^? crInv . ix j . itID . _Just
|
||||
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"
|
||||
setLocation :: World -> World
|
||||
setLocation w' = case maybeitid of
|
||||
|
||||
@@ -6,7 +6,7 @@ import Dodge.Picture
|
||||
--import Dodge.Picture.Layer
|
||||
import Dodge.Item.Attachment.Data
|
||||
--import Dodge.Base
|
||||
import Dodge.SoundLogic
|
||||
--import Dodge.SoundLogic
|
||||
import Dodge.WorldEvent.SpawnParticle
|
||||
import Dodge.WorldEvent.ThingsHit
|
||||
import Dodge.WorldEvent.HelperParticle
|
||||
@@ -25,7 +25,6 @@ import qualified Data.Sequence as Seq
|
||||
|
||||
aLaser :: Creature -> World -> World
|
||||
aLaser cr w = over particles (makeLaserAt phaseV pos dir : )
|
||||
$ soundFrom LasSound 24 1 0
|
||||
$ laserGunFlashAt (pos +.+ 5 *.* unitVectorAtAngle dir)
|
||||
w
|
||||
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)))
|
||||
(pushAmount, _) = randomR (-maxSide,maxSide) $ _randGen w
|
||||
{- | 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
|
||||
:: Int -- ^ Sound identifier
|
||||
-> Int -- ^ Frames to play
|
||||
|
||||
+13
-2
@@ -45,7 +45,8 @@ doDrawing pdata w = do
|
||||
wins = V2 (getWindowX w) (getWindowY w)
|
||||
(wallPointsCol,windowPoints) = wallsAndWindows w
|
||||
lightPoints = lightsForGloom w
|
||||
viewFroms = _cameraViewFrom w
|
||||
viewFroms@(V2 vfx vfy) = _cameraViewFrom w
|
||||
viewFrom3d = Vector3 vfx vfy 20
|
||||
shadV = _pictureShaders pdata
|
||||
-- bind as much data into vbos as feasible at this point
|
||||
-- poke wall points and colors
|
||||
@@ -72,10 +73,20 @@ doDrawing pdata w = do
|
||||
clear [ColorBuffer,DepthBuffer]
|
||||
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
|
||||
-- this might only work because the uniform has been correctly set
|
||||
-- elsewhere, beware
|
||||
-- indeed this is the case: this needs fixing
|
||||
|
||||
if w ^. config . wall_textured
|
||||
then renderTextureWalls pdata nWalls
|
||||
|
||||
+4
-3
@@ -38,11 +38,12 @@ createLightMap pdata lightPoints nWalls nSils nsurfVs = do
|
||||
clear [ColorBuffer,DepthBuffer]
|
||||
--colorMask $= Color4 Disabled Disabled Disabled Disabled
|
||||
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
|
||||
-- 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
|
||||
-- draw wall occlusions from your point of view
|
||||
-- draw wall occlusions from the camera's point of view
|
||||
drawShader (_lightingOccludeShader pdata) nWalls
|
||||
--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
|
||||
|
||||
Reference in New Issue
Block a user