How to use the arcade.key function in arcade

To help you get started, we’ve selected a few arcade examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pvcraven / arcade / examples / sprite_simple_platformer.py View on Github external
def on_key_release(self, key, modifiers):
        """
        Called when the user presses a mouse button.
        """
        if key == arcade.key.LEFT or key == arcade.key.RIGHT:
            self.player_sprite.change_x = 0
github pvcraven / arcade / arcade / examples / sprite_move_keyboard.py View on Github external
def on_key_release(self, key, modifiers):
        """Called when the user releases a key. """

        if key == arcade.key.UP or key == arcade.key.DOWN:
            self.player_sprite.change_y = 0
        elif key == arcade.key.LEFT or key == arcade.key.RIGHT:
            self.player_sprite.change_x = 0
github pvcraven / arcade / arcade / examples / pymunk_2.py View on Github external
self.mode = "Make Box"
        elif symbol == arcade.key.KEY_3:
            self.mode = "Make Circle"

        elif symbol == arcade.key.KEY_4:
            self.mode = "Make PinJoint"
        elif symbol == arcade.key.KEY_5:
            self.mode = "Make DampedSpring"

        elif symbol == arcade.key.S:
            self.space.gravity = (0.0, 0.0)
            self.space.damping = 1
        elif symbol == arcade.key.L:
            self.space.gravity = (0.0, 0.0)
            self.space.damping = 0
        elif symbol == arcade.key.G:
            sprite = CircleSprite(shape, "images/coin_01.png")
            self.space.damping = 0.95
            self.space.gravity = (0.0, -900.0)
github pvcraven / arcade / examples / sprite_move_keyboard.py View on Github external
def on_key_release(self, key, modifiers):
        """Called when the user releases a key. """

        if key == arcade.key.UP or key == arcade.key.DOWN:
            self.player_sprite.change_y = 0
        elif key == arcade.key.LEFT or key == arcade.key.RIGHT:
            self.player_sprite.change_x = 0
github pvcraven / arcade / arcade / examples / sprite_move_scrolling.py View on Github external
def on_key_release(self, key, modifiers):
        """Called when the user releases a key. """

        if key == arcade.key.UP or key == arcade.key.DOWN:
            self.player_sprite.change_y = 0
        elif key == arcade.key.LEFT or key == arcade.key.RIGHT:
            self.player_sprite.change_x = 0
github pvcraven / arcade / arcade / examples / platform_tutorial / 04_add_gravity.py View on Github external
def on_key_press(self, key, modifiers):
        """Called whenever a key is pressed. """

        if key == arcade.key.UP or key == arcade.key.W:
            if self.physics_engine.can_jump():
                self.player_sprite.change_y = PLAYER_JUMP_SPEED
        elif key == arcade.key.LEFT or key == arcade.key.A:
            self.player_sprite.change_x = -PLAYER_MOVEMENT_SPEED
        elif key == arcade.key.RIGHT or key == arcade.key.D:
            self.player_sprite.change_x = PLAYER_MOVEMENT_SPEED
github pvcraven / arcade / examples / sprite_ramps.py View on Github external
def on_key_release(self, key, modifiers):
        """
        Called when the user releases a key.
        """
        if key == arcade.key.LEFT or key == arcade.key.RIGHT:
            self.player_sprite.change_x = 0
github pvcraven / arcade / arcade / examples / view_screens_minimal.py View on Github external
def on_key_press(self, key, _modifiers):
        if key == arcade.key.ESCAPE:
            menu_view = MenuView()
            self.window.show_view(menu_view)
github pvcraven / arcade / arcade / examples / platform_tutorial / 11_animate_character.py View on Github external
def on_key_press(self, key, modifiers):
        """Called whenever a key is pressed. """

        if key == arcade.key.UP or key == arcade.key.W:
            self.up_pressed = True
        elif key == arcade.key.DOWN or key == arcade.key.S:
            self.down_pressed = True
        elif key == arcade.key.LEFT or key == arcade.key.A:
            self.left_pressed = True
        elif key == arcade.key.RIGHT or key == arcade.key.D:
            self.right_pressed = True

        self.process_keychange()
github pvcraven / arcade / examples / sprite_simple_platformer.py View on Github external
def on_key_press(self, key, modifiers):
        """
        Called whenever the mouse moves.
        """
        if key == arcade.key.UP:
            if self.physics_engine.can_jump():
                self.player_sprite.change_y = JUMP_SPEED
        elif key == arcade.key.LEFT:
            self.player_sprite.change_x = -MOVEMENT_SPEED
        elif key == arcade.key.RIGHT:
            self.player_sprite.change_x = MOVEMENT_SPEED