This commit is contained in:
2021-03-21 23:05:11 +01:00
6 changed files with 27 additions and 3 deletions
+2
View File
@@ -1,3 +1,5 @@
.stack-work/ .stack-work/
*~ *~
*.swp *.swp
loop.cabal
*.lock
+2 -1
View File
@@ -1874,7 +1874,7 @@ yourControl :: World -> (World -> World,StdGen) -> Creature -> ((World -> World,
yourControl w (f,g) cr = ( (mouseActionsWorld (_mouseButtons w) . f, g) yourControl w (f,g) cr = ( (mouseActionsWorld (_mouseButtons w) . f, g)
, Just . crAutoReload . mouseActionsCr (_mouseButtons w) $ wasdWithAiming w speed strafeSpeed 0 cr , Just . crAutoReload . mouseActionsCr (_mouseButtons w) $ wasdWithAiming w speed strafeSpeed 0 cr
) )
where strafeSpeed = 3 * equipFactor * (fromMaybe 1 $ yourItem w ^? itAimingSpeed) where strafeSpeed = 8 * equipFactor * (fromMaybe 1 $ yourItem w ^? itAimingSpeed)
speed = 3 * equipFactor speed = 3 * equipFactor
equipFactor = product $ map equipSpeed $ IM.elems $ _crInv $ _creatures w IM.! 0 equipFactor = product $ map equipSpeed $ IM.elems $ _crInv $ _creatures w IM.! 0
@@ -1932,6 +1932,7 @@ wasdWithAiming w speed aimSpeed i cr
*.* rotateV (_cameraRot w) (_mousePos w) *.* rotateV (_cameraRot w) (_mousePos w)
_ -> normalizeAngle $ argV (_mousePos w) + _cameraRot w _ -> normalizeAngle $ argV (_mousePos w) + _cameraRot w
wasdM :: SDL.Keycode -> Point2 wasdM :: SDL.Keycode -> Point2
wasdM SDL.KeycodeW = (0,1) wasdM SDL.KeycodeW = (0,1)
wasdM SDL.KeycodeS = (0,-1) wasdM SDL.KeycodeS = (0,-1)
+1
View File
@@ -86,6 +86,7 @@ data World = World
, _lightSources :: !(IM.IntMap LightSource) , _lightSources :: !(IM.IntMap LightSource)
, _tempLightSources :: ![TempLightSource] , _tempLightSources :: ![TempLightSource]
, _closeActiveObjects :: [Either FloorItem Button] , _closeActiveObjects :: [Either FloorItem Button]
, _remap :: Keycode -> Keycode
} --deriving (Show) } --deriving (Show)
type Drawing = Picture type Drawing = Picture
+18 -2
View File
@@ -39,12 +39,26 @@ handleKeyEvent w kev = case keyboardEventKeyMotion kev of
Released -> Just $ over keys (S.delete $ getKeycode kev) w Released -> Just $ over keys (S.delete $ getKeycode kev) w
_ -> handlePressedKeyEvent (addKey (getKeycode kev) w) (keyboardEventRepeat kev) (getKeycode kev) _ -> handlePressedKeyEvent (addKey (getKeycode kev) w) (keyboardEventRepeat kev) (getKeycode kev)
where getKeycode :: KeyboardEventData -> Keycode where getKeycode :: KeyboardEventData -> Keycode
getKeycode = keysymKeycode . keyboardEventKeysym getKeycode = _remap w . keysymKeycode . keyboardEventKeysym
addKey :: Keycode -> World -> World addKey :: Keycode -> World -> World
addKey k = over keys $ S.insert k addKey k = over keys $ S.insert k
handlePressedKeyEvent :: World -> Bool -> Keycode -> Maybe World -- Basic key remapping for a dvorak key layout
keyremap :: Keycode -> Keycode
keyremap KeycodeComma = KeycodeW
keyremap KeycodeA = KeycodeA
keyremap KeycodeE = KeycodeD
keyremap KeycodeO = KeycodeS
keyremap KeycodeSlash = KeycodeQ
keyremap KeycodePeriod = KeycodeE
keyremap KeycodeP = KeycodeR
keyremap KeycodeU = KeycodeF
keyremap k = k
keyremapDefault :: Keycode -> Keycode
keyremapDefault k = k
handlePressedKeyEvent w True _ = Just w handlePressedKeyEvent w True _ = Just w
handlePressedKeyEvent w _ keycode handlePressedKeyEvent w _ keycode
= case keycode of = case keycode of
@@ -58,6 +72,8 @@ handlePressedKeyEvent w _ keycode
KeycodeSpace -> Just $ spaceAction w KeycodeSpace -> Just $ spaceAction w
KeycodeQ -> Just $ w {_cameraRot = _cameraRot w + 0.01} KeycodeQ -> Just $ w {_cameraRot = _cameraRot w + 0.01}
KeycodeE -> Just $ w {_cameraRot = _cameraRot w - 0.01} KeycodeE -> Just $ w {_cameraRot = _cameraRot w - 0.01}
KeycodeF1 -> Just $ w {_remap = keyremap}
KeycodeF2 -> Just $ w {_remap = keyremapDefault}
_ -> Just w _ -> Just w
handleMouseMotionEvent :: World -> MouseMotionEventData -> Maybe World handleMouseMotionEvent :: World -> MouseMotionEventData -> Maybe World
+3
View File
@@ -19,6 +19,7 @@ import qualified Data.Map as M
import qualified Data.Set as S import qualified Data.Set as S
import Data.Graph.Inductive.Graph hiding ((&)) import Data.Graph.Inductive.Graph hiding ((&))
import Data.List import Data.List
import Dodge.KeyEvents (keyremapDefault)
-- defalt datatypes / prototypes {{{ -- defalt datatypes / prototypes {{{
basicWall = Wall { _wlLine = [(0,0),(50,0)] basicWall = Wall { _wlLine = [(0,0),(50,0)]
@@ -175,6 +176,7 @@ basicPP = PressPlate
, _ppText = "Pressure plate" , _ppText = "Pressure plate"
} }
-- }}} -- }}}
basicWorld = World basicWorld = World
{ _keys = S.empty { _keys = S.empty
, _mouseButtons = S.empty , _mouseButtons = S.empty
@@ -223,6 +225,7 @@ basicWorld = World
, _lightSources = IM.empty , _lightSources = IM.empty
, _tempLightSources = [youLight] , _tempLightSources = [youLight]
, _closeActiveObjects = [] , _closeActiveObjects = []
, _remap = keyremapDefault
} }
youLight = youLight =
-- LS {_lsEff = \w _ p -> (logistic 1 1 1 (d p w * 0.01) ) -- LS {_lsEff = \w _ p -> (logistic 1 1 1 (d p w * 0.01) )
+1
View File
@@ -215,6 +215,7 @@ compileAndCheckShader str (shaderType,sourceCode) = do
putStrLn $ str ++ ": Shader compile: " ++ show shaderType ++ " : " ++ show infoLog putStrLn $ str ++ ": Shader compile: " ++ show shaderType ++ " : " ++ show infoLog
return theShader return theShader
resetShaderUniforms :: [(Program, [UniformLocation])] -> IO ()
resetShaderUniforms = setShaderUniforms 0 1 (0,0) (2,2) resetShaderUniforms = setShaderUniforms 0 1 (0,0) (2,2)
{-# INLINE resetShaderUniforms #-} {-# INLINE resetShaderUniforms #-}