def checkRawKeyHeld(symbol): for key in KEY_LIST: try: if keyMatches(key, symbol): if checkKeyHeld(key): return True except NotImplementedError: pass return False
def _registerHeld(symbol, modifiers): for key in KEY_LIST: try: if keyMatches(key, symbol): keys_held.add(key) break except NotImplementedError: pass return False
def _registerReleased(symbol, modifiers): for key in KEY_LIST: try: if keyMatches(key, symbol): try: keys_held.remove(key) except KeyError: pass break except NotImplementedError: pass return False
def keyPressed(self, symbol, modifiers): if not self.mappe.getScreenTransitioning( ) and not self.hurt_control_loss and not self.swinging_sword and not self.charging and not self.paused: if keyMatches(CANCEL, symbol): if self.form != PLAYER_FORM_INDEX: if not self.checkOverPit( ): #don't allow this if flying over a pit self.setPlayerForm(PLAYER_FORM_INDEX) playSound(SOUND_BLOORP, True) else: if not self.bubble_exists: self.setBubbleExists(True) bubble = self.mappe.getActor( self.mappe.addActor(RainbowBubble)) bubble.setPos(*map( operator.add, self.getPos(), PROJECTILE_OFFSET_DICT.get(self.facing, (0, 0)))) bubble.setBubbleDirection(self.facing) playSound(SOUND_SHOOT, True) elif keyMatches(CONFIRM, symbol): if self.form == ENEMY_SKELETON_INDEX and not self.swinging_sword: self.setVelocity(0, 0) self.swinging_sword = True self.setSpriteAnimation( SKELETON_ANI_DICT[self.facing][0][0]) self.setSpriteFlip(SKELETON_ANI_DICT[self.facing][1]) self.Schedule(self._swingSword, PLAYER_SKELETON_BACKSWING_TIME) elif self.form == ENEMY_MINOTAUR_INDEX and not self.charging: self.charging = True self.charging_windup = True self.setVelocity(0, 0) self.setSpriteAnimation( ACTOR_MOVEMENT_ANIMATION_DICT[self.facing][True][0]) self.setSpriteAnimationSpeed(2.0) playSound(SOUND_RUNNING, True) self.Schedule(self._startCharge, PLAYER_CHARGE_WINDUP_TIME)
def respondKeyPress(self, symbol, modifiers): if keyMatches(CANCEL, symbol): customEvent(PLAYER_JUMP_EVENT) return False