Cleanup and reorganise
This commit is contained in:
@@ -1,10 +1,8 @@
|
||||
module Dodge.Creature.YourControl
|
||||
where
|
||||
( yourControl
|
||||
) where
|
||||
import Dodge.Data
|
||||
--import Dodge.Base
|
||||
import Dodge.Creature.Impulse.Movement
|
||||
--import Dodge.Creature.State
|
||||
--import Dodge.Creature.State.Data
|
||||
import Dodge.Creature.Stance.Data
|
||||
import Dodge.Update.UsingInput
|
||||
import Dodge.Config.KeyConfig
|
||||
@@ -13,10 +11,8 @@ import Geometry
|
||||
|
||||
import Control.Lens
|
||||
import qualified SDL
|
||||
--import Data.Maybe
|
||||
import qualified Data.Set as S
|
||||
import qualified Data.IntMap.Strict as IM
|
||||
--import System.Random
|
||||
import Data.Monoid
|
||||
{- | The AI equivalent for your control. -}
|
||||
yourControl
|
||||
@@ -57,26 +53,19 @@ wasdWithAiming w speed i cr
|
||||
|
||||
wasdM :: World -> SDL.Scancode -> Point2
|
||||
wasdM w scancode
|
||||
| scancode == moveUpKey (_keyConfig w) = V2 0 1
|
||||
| scancode == moveDownKey (_keyConfig w) = V2 0 (-1)
|
||||
| scancode == moveRightKey (_keyConfig w) = V2 1 0
|
||||
| scancode == moveLeftKey (_keyConfig w) = V2 (-1) 0
|
||||
| scancode == moveUpKey (_keyConfig w) = V2 0 1
|
||||
| scancode == moveDownKey (_keyConfig w) = V2 0 (-1)
|
||||
| scancode == moveRightKey (_keyConfig w) = V2 1 0
|
||||
| scancode == moveLeftKey (_keyConfig w) = V2 (-1) 0
|
||||
wasdM _ _ = V2 0 0
|
||||
|
||||
wasdDir :: World -> Point2
|
||||
wasdDir w = foldr ((+.+) . wasdM w) (V2 0 0) $ _keys w
|
||||
|
||||
wasdComp :: S.Set SDL.Scancode -> World -> (Point2,Maybe Float)
|
||||
wasdComp ks w = f $ foldr ( (+.+) . wasdM w ) (V2 0 0) ks
|
||||
where
|
||||
f (V2 0 0) = (V2 0 0, Nothing)
|
||||
f p = (errorNormalizeV 46 p, Just $ argV p)
|
||||
|
||||
{- | Set posture according to mouse presses. -}
|
||||
mouseActionsCr :: S.Set SDL.MouseButton -> Creature -> Creature
|
||||
mouseActionsCr pkeys
|
||||
| rbPressed = crStance . posture .~ Aiming
|
||||
| otherwise = crStance . posture .~ AtEase
|
||||
where
|
||||
--lbPressed = SDL.ButtonLeft `S.member` pkeys
|
||||
rbPressed = SDL.ButtonRight `S.member` pkeys
|
||||
|
||||
Reference in New Issue
Block a user