@maxbilbow maxbilbow released this May 18, 2015 · 18 commits to 0.10.x since this release

Assets 3
/// Contains Keys control mapping for a desktop interface.
///
/// For example, the following gives a forward momentum of '2' when 'w' is pressed, and 0 when 'w' is released:
///
///   let MOVE_SPEED: (on:RMFloat,off:RMFloat) = (2, 0)
///   var key = RMKey(self, action: "forward", characters: "w", speed: MOVE_SPEED)
///
/// The RMSActionProcessor class handles the application of the human term "forward", regardless of interface used. See also `RMXDPad` for iOS.
///
/// See also: `RMKeys` and  `RMSActionProcessor`.
class RMSKeys : RMXInterface {

    ///Key down, Key up options
    static let ON_KEY_DOWN: (on:RMFloat,off:RMFloat) = (1,0)
    static let ON_KEY_UP: (on:RMFloat,off:RMFloat) = (0,1)
    static let MOVE_SPEED: (on:RMFloat,off:RMFloat) = (RMXInterface.moveSpeed * 2, 0)
    static let LOOK_SPEED: (on:RMFloat,off:RMFloat) = (RMXInterface.lookSpeed * 10, 0)

    ///Key settings
    lazy var keys: [ RMKey ] = [

    // Basic Movement
    RMKey(self, action: "forward", characters: "w", speed: MOVE_SPEED),
    RMKey(self, action: "back", characters: "s", speed: MOVE_SPEED),
    RMKey(self, action: "left", characters: "a", speed: MOVE_SPEED),
    RMKey(self, action: "right", characters: "d", speed: MOVE_SPEED),
    RMKey(self, action: "up", characters: "e", speed: MOVE_SPEED),
    RMKey(self, action: "down", characters: "q", speed: MOVE_SPEED),
    RMKey(self, action: "rollLeft", characters: "z", speed: LOOK_SPEED),
    RMKey(self, action: "rollRight", characters: "x", speed: LOOK_SPEED),
    RMKey(self, action: "jump", characters: " "),
    RMKey(self, action: "look", characters: "mouseMoved", isRepeating: false,speed: (0.01,0)),

    //Interactions
    RMKey(self, action: "grab", characters: "Mouse 1", isRepeating: false, speed: ON_KEY_UP),
    RMKey(self, action: "throw", characters: "Mouse 2", isRepeating: false,  speed: (0,20)),

    //Environmentals
    RMKey(self, action: "toggleAllGravity", characters: "g", isRepeating: false,speed: ON_KEY_UP),
    //RMKey(self, action: "toggleGravity", characters: "G", isRepeating: false,speed: ON_KEY_UP),
    RMKey(self, action: "toggleAI", characters: "A", isRepeating: false,speed: ON_KEY_UP),
    RMKey(self, action: "reset", characters: "R", isRepeating: false,speed: ON_KEY_UP),

    //Interface options
    RMKey(self, action: "lockMouse", characters: "m", isRepeating: false, speed: ON_KEY_UP),
    RMKey(self, action: "nextCamera", characters: ".", isRepeating: false, speed: ON_KEY_DOWN),
    RMKey(self, action: "previousCamera", characters: ",", isRepeating: false, speed: ON_KEY_DOWN),

    //Misc: generically used for testing
    RMKey(self, action: "information", characters: "i", isRepeating: false,speed: ON_KEY_DOWN), //Prints to terminal when testing
    RMKey(self, action: "increase", characters: "=", isRepeating: false, speed: ON_KEY_DOWN),
    RMKey(self, action: "decrease", characters: "-", isRepeating: false, speed: ON_KEY_DOWN)
    ]