def __init__(self, inputWatcher, window, defaultKeys = []): ''' Creates a new ControlScheme object. @param inputWatcher: The MouseWatcher object to use for tracking the mouse and keys. @param defaultKeys: is a collection of key types to be initialized by default (optional). Acceptable values are "left", "right", "up", "down", and "pause". The defaults for directional keys are the arrows, WASD, and the equivalents of WASD on common alternate keyboard layouts. The keys for "pause" are escape, p, and enter. ''' self.inputWatcher = inputWatcher self.window = window properties = window.getProperties() self.centerX = properties.getXSize() // 2 self.centerY = properties.getYSize() // 2 self.prevMouseX = self.centerX self.keyMap = dict() self.addKeys(LEFT, [KeyboardButton.left(), KeyboardButton.asciiKey('a'), KeyboardButton.asciiKey('q')]) self.addKeys(RIGHT, [KeyboardButton.right(), KeyboardButton.asciiKey('d'), KeyboardButton.asciiKey('e')]) self.addKeys(UP, [KeyboardButton.up(), KeyboardButton.asciiKey('w'), KeyboardButton.asciiKey('z'), KeyboardButton.asciiKey(',')]) self.addKeys(DOWN, [KeyboardButton.down(), KeyboardButton.asciiKey('s'), KeyboardButton.asciiKey('o')]) self.addKeys(PAUSE, [KeyboardButton.escape(), KeyboardButton.asciiKey('p'), KeyboardButton.enter()]) self.addKeys(SWITCH, [KeyboardButton.shift(), KeyboardButton.control(), KeyboardButton.asciiKey('f'), KeyboardButton.asciiKey('/'), MouseButton.two(), KeyboardButton.space()]) self.addKeys(PUSH, [MouseButton.one()]) self.addKeys(PULL, [MouseButton.three()]) self.addKeys(QUIT, [KeyboardButton.asciiKey('q')]) #in case the mouse leaves the window self.mouseX = 0 self.mouseY = 0