Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
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
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)
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
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
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
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
def on_key_press(self, key, _modifiers):
if key == arcade.key.ESCAPE:
menu_view = MenuView()
self.window.show_view(menu_view)
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()
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