Example #1
0
 def isKeyPressed(key):
   return Keyboard.is_key_pressed(key)
Example #2
0
 def held(self):
     return Keyboard.is_key_pressed(self.value)
Example #3
0
    def handle_keys(self):
        """Simple key handling. Does not return values, except for the ESC key!"""

        if Keyboard.is_key_pressed(Keyboard.ESCAPE):
            return "quit"

        if Keyboard.is_key_pressed(Keyboard.E):
            self.player.turn(TURN_SPEED)
        elif Keyboard.is_key_pressed(Keyboard.Q):
            self.player.turn(-TURN_SPEED)

        if Keyboard.is_key_pressed(Keyboard.A):
            self.player.strafing = True
            self.player.strafe(PLAYER_SPEED, "left")

        elif Keyboard.is_key_pressed(Keyboard.D):
            self.player.strafing = True
            self.player.strafe(PLAYER_SPEED, "right")

        if Keyboard.is_key_pressed(Keyboard.W):
            self.player.move(PLAYER_SPEED, "forward")
            if self.bob_top == True:
                if self.player.bob < 5:
                    self.player.bob += 0.5
                else:
                    self.bob_top = False
            elif self.bob_top == False:
                if self.player.bob > -5:
                    self.player.bob -= 0.5
                else:
                    self.bob_top = True

        elif Keyboard.is_key_pressed(Keyboard.S):
            self.player.move(PLAYER_SPEED, "backward")
            if self.bob_top == True:
                if self.player.bob < 5:
                    self.player.bob += 0.5
                else:
                    self.bob_top = False
            elif self.bob_top == False:
                if self.player.bob > -5:
                    self.player.bob -= 0.5
                else:
                    self.bob_top = True

        if Keyboard.is_key_pressed(Keyboard.SPACE):
            self.open_doors()

        if (
            Keyboard.is_key_pressed(Keyboard.R_CONTROL)
            and self.player.attack_delay == 0
            and self.player.attack == False
        ):
            self.player.attack = True
            self.player.attack_delay = 15

        if Keyboard.is_key_pressed(Keyboard.NUM1) and self.knife.enabled == 1:
            self.player.weapon = self.knife
        elif Keyboard.is_key_pressed(Keyboard.NUM2) and self.pistol.enabled == 1:
            self.player.weapon = self.pistol
        elif Keyboard.is_key_pressed(Keyboard.NUM3) and self.rifle.enabled == 1:
            self.player.weapon = self.rifle

        # DEBUG KEYS
        if Keyboard.is_key_pressed(Keyboard.P):
            if self.player.hp + 5 <= 100:
                self.player.hp += 5
        elif Keyboard.is_key_pressed(Keyboard.O):
            if self.player.hp - 5 >= 0:
                self.player.hp -= 5

        if Keyboard.is_key_pressed(Keyboard.R_BRACKET):
            if self.player.score + 55 < 9999:
                self.player.score += 55
        elif Keyboard.is_key_pressed(Keyboard.L_BRACKET):
            if self.player.score - 55 >= 0:
                self.player.score -= 55
Example #4
0
    def handle_keys(self):
        """Simple key handling. Does not return values, except for the ESC key!"""

        if Keyboard.is_key_pressed(Keyboard.ESCAPE):
            return 'quit'

        if Keyboard.is_key_pressed(Keyboard.E):
            self.player.turn(TURN_SPEED)
        elif Keyboard.is_key_pressed(Keyboard.Q):
            self.player.turn(-TURN_SPEED)

        if Keyboard.is_key_pressed(Keyboard.A):
            self.player.strafing = True
            self.player.strafe(PLAYER_SPEED, "left")

        elif Keyboard.is_key_pressed(Keyboard.D):
            self.player.strafing = True
            self.player.strafe(PLAYER_SPEED, "right")

        if Keyboard.is_key_pressed(Keyboard.W):
            self.player.move(PLAYER_SPEED, "forward")
            if self.bob_top == True:
                if self.player.bob < 5:
                    self.player.bob += .5
                else:
                    self.bob_top = False
            elif self.bob_top == False:
                if self.player.bob > -5:
                    self.player.bob -= .5
                else:
                    self.bob_top = True

        elif Keyboard.is_key_pressed(Keyboard.S):
            self.player.move(PLAYER_SPEED, "backward")
            if self.bob_top == True:
                if self.player.bob < 5:
                    self.player.bob += .5
                else:
                    self.bob_top = False
            elif self.bob_top == False:
                if self.player.bob > -5:
                    self.player.bob -= .5
                else:
                    self.bob_top = True

        if Keyboard.is_key_pressed(Keyboard.SPACE):
            self.open_doors()

        if Keyboard.is_key_pressed(
                Keyboard.R_CONTROL
        ) and self.player.attack_delay == 0 and self.player.attack == False:
            self.player.attack = True
            self.player.attack_delay = 15

        if Keyboard.is_key_pressed(Keyboard.NUM1) and self.knife.enabled == 1:
            self.player.weapon = self.knife
        elif Keyboard.is_key_pressed(
                Keyboard.NUM2) and self.pistol.enabled == 1:
            self.player.weapon = self.pistol
        elif Keyboard.is_key_pressed(
                Keyboard.NUM3) and self.rifle.enabled == 1:
            self.player.weapon = self.rifle

        # DEBUG KEYS
        if Keyboard.is_key_pressed(Keyboard.P):
            if self.player.hp + 5 <= 100:
                self.player.hp += 5
        elif Keyboard.is_key_pressed(Keyboard.O):
            if self.player.hp - 5 >= 0:
                self.player.hp -= 5

        if Keyboard.is_key_pressed(Keyboard.R_BRACKET):
            if self.player.score + 55 < 9999:
                self.player.score += 55
        elif Keyboard.is_key_pressed(Keyboard.L_BRACKET):
            if self.player.score - 55 >= 0:
                self.player.score -= 55
Example #5
0
		def held(self):
			return Keyboard.is_key_pressed(self.value)