1 ----------------------------------------
2 {- Module : Basic Keyboard Actions
3 Copyright : BSD License
5 Maintainer : Berlin Brown
8 Description : Basic Keyboard Actions
12 ----------------------------------------
14 module MechKeys
(mechKeyboardHandler
) where
16 import Graphics
.UI
.GLUT
17 import System
.Exit
( exitWith, ExitCode(..) )
22 import Debug
.Trace
( trace
)
25 -- Mech Keyboard Action
26 -- mechKeyboardAct :: Map.Map k a -> Key -> KeyState -> SimplePlayer
27 mechKeyboardAct mech
(SpecialKey KeyLeft
) Down
= mech
{posX
= (posX mech
) - ssize
}
28 mechKeyboardAct mech
(SpecialKey KeyRight
) Down
= mech
{posX
= (posX mech
) + ssize
}
29 mechKeyboardAct mech
(SpecialKey KeyUp
) Down
= mech
{posY
= (posY mech
) + ssize
}
30 mechKeyboardAct mech
(SpecialKey KeyDown
) Down
= mech
{posY
= (posY mech
) - ssize
}
32 mechKeyboardAct mech
(Char 'w
') Down
= mech
33 mechKeyboardAct mech
(Char 'a
') Down
= mech
34 mechKeyboardAct mech
(Char 's
') Down
= mech
35 mechKeyboardAct mech
(Char 'd
') Down
= mech
37 mechKeyboardAct mech
(Char '\27') Down
= escapeKeyHandler mech
38 mechKeyboardAct mech _ _
= mech
41 -- Debug trace escape key handler
42 escapeKeyHandler
:: SimplePlayer
-> SimplePlayer
43 escapeKeyHandler mechRef
=
44 trace
("INFO: exiting")
48 -- Mech Keyboard Handler, given the mech object reference and the
49 -- [ key, state, modifiers, and keyboard pos ]
50 mechKeyboardHandler mechRef key state modifiers position
= do
52 mechRef
$= mechKeyboardAct mech key state